Why the stmt is always null
843853Sep 21 2001 — edited Sep 25 2001Hi,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!