Hi ,All
Does anybody use THINWEB.com JDBC driver( type4) to connect with MS SQL server 7.0?
i try to test this driver but failed?
Does anyone figure out whats problem with following code:
mport java.sql.*;
class TestMsql7 {
public static void main(String argv[]) {
try {
String url = "jdbc:twtds:sqlserver://192.168.1.5:1433/pubs;CHARSET=cp950;TDS=4.2";
System.out.println("Attempting to connect..");
Connection con = DriverManager.getConnection(url,"sa","");
System.out.println("Connection establised");
// Create statement
Statement stmt = con.createStatement();
// Execute query
String query = "select * from sales";
// Obtain the result set
ResultSet rs = stmt.executeQuery(query);
System.out.println("JDBC SQL Query : "+query);
System.out.println("Results : ");
// Loop through each result row
while(rs.next()) { // Null point exception
// Print out each field as a string
System.out.print(rs.getString("qty"));
System.out.println("");
}
rs.close();
stmt.close();
con.close();
}
catch( Exception e ) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
}
Run Result:
Attempting to connect..
Connection establised
JDBC SQL Query : select * from sales
Results :
null
java.lang.NullPointerException
at com.thinweb.tds.Tds.b(Unknown Source)
at com.thinweb.tds.Tds.a(Unknown Source)
at com.thinweb.tds.ResultSet.next(Unknown Source)
at TestMsql7.main(TestMsql7.java:25)