Connection to JDBC
Hello friends,
i am having a file called DBBean.java and the source code is
public class DBBean extends java.lang.Object {
/* Database attributes */
privateConnectionconnection ;
privateStringclassname= "sun.jdbc.odbc.JdbcOdbcDriver";
privateStringurl= "jdbc:odbc:HemaMetrics";
privateStringusername= "HemaMetrics";
privateStringpassword= "HemaMetrics";
protectedVectorresult, colNames;
protectedintrows, cols;
protectedintnPrecision = 2;
protectedResultSetMetaData rsmd;
/***************************************************************************
* For date formatting.
***************************************************************************
*/
privateStringfromDatePattern = "yyyy-mm-dd HH:mm:ss.S";
privateStringtoDatePattern = "dd/mm/yyyy";
protectedboolean formatDate = false;
/***************************************************************************
* For administration/debugging the bean.
***************************************************************************
*/
protectedbooleandebug = false;
public DBBean()
throws SQLException, ClassNotFoundException
{
/* Load JdbcOdbcDriver */
/*Class.forName(classname).newInstance();*/
/* Get the connection using DSN-HemaMetrics, UserId-HemaMetrics,
* Password-HemaMetrics */
connection=DriverManager.getConnection(url, username, password);
connection.setAutoCommit(true);
}
public DBBean(String url, String username, String password)
throws SQLException, ClassNotFoundException
{
/* Load JdbcOdbcDriver */
Class.forName(classname);
this.url = url;
this.username = username;
this.password = password;
/* Get the connection with the given parameters to the method */
connection=DriverManager.getConnection(url, username, password);
connection.setAutoCommit(true);
}
}
i want to use this connection in the following User.java
in this User.java i am creating a obj as follows
Connection conn;
DBBean Cdb = new DBBean();
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
i am not getting the connection in to the User.java and How to get the Connection in User.java
Please Help Me
thanks
Chilakala

