Hi, I'm new at java programming and wanted to do some first steps calling some data from a MS SQL server table (changing to mysql or any other db system is out of the question) and I'm using the jtds library, the connection is good, but can't get any data and I don't know why that is, please someone point me in the right direction
Class.forName("net.sourceforge.jtds.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:jtds:sqlserver://192.168.0.1:1433/MyDB", "sa", "myPass"); Statement stt = conn.createStatement(); ResultSet rs = stt.executeQuery("select code from MyDB.dbo.table"); while (rs.next()) { System.out.print(rs.getInt(0)); } rs.close(); conn.close();
I put a breakpoint in the while line but the rs seems to be empty, and it never goes inside the loop, the connection seems to be fine, i can connect from my macbook to the server and make queries, no problem there, I just can't explain what happens, I was wondering where can I see the error, I'm using Eclipse Helios.
Thanks.