File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

com.thinweb.tds.Driver for Ms SQL 7

 
sean zang
Ranch Hand
Posts: 33
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic