Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Why the stmt is always null

843853Sep 21 2001 — edited Sep 25 2001
Hi,friends
I used the JdbcOdbc drive to connect to MS SQL 2000 and the connection was established but the statement way always null. The following is the code snippet from my class:

public ResultSet executeQuery(String sql) {
ReultSet rs = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection conn = DriverManager.getConnection("jdbc:odbc:my_odbc_dsn","my_name","my_password");

Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

rs = stmt.executeQuery("select * from my_table");
}
catch(SQLException E) {
System.err.println(E.getMessage());
}
return rs;
}

Where the my_odbc_dsn is a Data Source Name i have built.I have used TYPE_SCROLL_SENSITIVE,FORWARD_ONLY instead of TYPE_SCROLL_INSENSITIVE but it still doesnot work!

Hope get your help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 23 2001
Added on Sep 21 2001
8 comments
322 views