mysql-server
Posted: Thu Jan 08, 2015 6:55 am
I am having trouble connecting to an SQL server I set up on the raspberry pi. When I try to connect to it, I get an error(using jtds 1.3.1):
java.sql.SQLException: I/O Error: Unknown packet type 0x42
code:
Connection conn = null;
ResultSet rs = null;
String url = "jdbc:jtds:sqlserver://xxxxxxxxxx;DatabaseName=xxxxx";
String driver = "net.sourceforge.jtds.jdbc.Driver";
String userName = "xxxx";
String password = "xxxxxxxxx";
try {
Class.forName(driver);
conn = DriverManager.getConnection(url, userName, password);
System.out.println("Connected to the database!!! Getting table list...");
DatabaseMetaData dbm = conn.getMetaData();
rs = dbm.getTables(null, null, "%", new String[] { "TABLE" });
while (rs.next()) { System.out.println(rs.getString("TABLE_NAME")); }
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
conn.close();
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I also tried using sqljdbc but got a different error:
com.microsoft.sqlserver.jdbc.SQLServerException: The TDS prelogin response is incomplete. The target server must be SQL Server 2000 or later.
code:
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://xxxxxxxxxx",
"xxxxx", "xxxxxxxx");
System.out.println("connected");
Statement statement = conn.createStatement();
String queryString = "select * from testTable";
ResultSet rs = statement.executeQuery(queryString);
while (rs.next()) {
System.out.println(rs.getString(1));
}
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
Obviously something is wrong, I just have no idea where to start... Here is my java code to connect to it. The server version is 5.5.40-0+wheezy1 (Debian). I have tried for hours to fix this issue, but I just cant seem to get it...
Note: I have a valid connection to it, the connection is not the issue.
java.sql.SQLException: I/O Error: Unknown packet type 0x42
code:
Connection conn = null;
ResultSet rs = null;
String url = "jdbc:jtds:sqlserver://xxxxxxxxxx;DatabaseName=xxxxx";
String driver = "net.sourceforge.jtds.jdbc.Driver";
String userName = "xxxx";
String password = "xxxxxxxxx";
try {
Class.forName(driver);
conn = DriverManager.getConnection(url, userName, password);
System.out.println("Connected to the database!!! Getting table list...");
DatabaseMetaData dbm = conn.getMetaData();
rs = dbm.getTables(null, null, "%", new String[] { "TABLE" });
while (rs.next()) { System.out.println(rs.getString("TABLE_NAME")); }
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
conn.close();
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
I also tried using sqljdbc but got a different error:
com.microsoft.sqlserver.jdbc.SQLServerException: The TDS prelogin response is incomplete. The target server must be SQL Server 2000 or later.
code:
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlserver://xxxxxxxxxx",
"xxxxx", "xxxxxxxx");
System.out.println("connected");
Statement statement = conn.createStatement();
String queryString = "select * from testTable";
ResultSet rs = statement.executeQuery(queryString);
while (rs.next()) {
System.out.println(rs.getString(1));
}
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
Obviously something is wrong, I just have no idea where to start... Here is my java code to connect to it. The server version is 5.5.40-0+wheezy1 (Debian). I have tried for hours to fix this issue, but I just cant seem to get it...
Note: I have a valid connection to it, the connection is not the issue.