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

[2453 byte] By [Chilakalaa] at [2007-10-3 2:27:58]
# 1
1) http://forum.java.sun.com/help.jspa?sec=formatting2) How about posting the code that fails? Because your three lines would't even compile with conn being uninitialized3) How about telling us the error message?
CeciNEstPasUnProgrammeura at 2007-7-14 19:27:02 > top of Java-index,Java Essentials,New To Java...
# 2
How to Intialise a conn in User.javathat is my main problemDBBean Cdb = new DBBean();after writing the above code only i will get the conn know.
Chilakalaa at 2007-7-14 19:27:02 > top of Java-index,Java Essentials,New To Java...