hi,I've a java program that connects to a sql server database using jtds 1.2.the client box(which is a winxp box) is in the same domain as the server box.Here is the code (hope it will be readable):
public class Main {
public static void main(String[] args) {
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
String connectionUrl = "jdbc:jtds:sqlserver://192.168.1.82:1433/pubs;namedPipe=true";
String user = "sa";
String pass = "test";
Connection con = DriverManager.getConnection(connectionUrl, user, pass);
String SQL = "select * from authors";
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(SQL);
while (rs.next()) {
System.out.println(rs.getString("au_lname") + ", " + rs.getString("au_fname"));
}
rs.close();
stmt.close();
} catch (ClassNotFoundException ex) {
ex.printStackTrace();
} catch (SQLException ex) {
ex.printStackTrace();
}
}
}
This program works correctly.But when i switch to a linux box (not in the server 's domain),i get the following error:
java.sql.SQLException: Network error IOException: Logon failure: unknown user name or bad password.
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:372)
at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:178)
at java.sql.DriverManager.getConnection(DriverManager.java:548)
at java.sql.DriverManager.getConnection(DriverManager.java:179)
at usingsqlserverfromjava.Main.main(Main.java:40)
Caused by: jcifs.smb.SmbAuthException: Logon failure: unknown user name or bad password.
at jcifs.smb.SmbTransport.send(SmbTransport.java:689)
at jcifs.smb.SmbSession.sessionSetup(SmbSession.java:271)
at jcifs.smb.SmbSession.send(SmbSession.java:228)
at jcifs.smb.SmbTree.treeConnect(SmbTree.java:134)
at jcifs.smb.SmbFile.connect(SmbFile.java:827)
at jcifs.smb.SmbFile.connect0(SmbFile.java:797)
at jcifs.smb.SmbFile.open0(SmbFile.java:852)
at jcifs.smb.SmbFile.open(SmbFile.java:881)
at jcifs.smb.SmbFileOutputStream.<init>(SmbFileOutputStream.java:139)
at jcifs.smb.SmbNamedPipe.getNamedPipeOutputStream(SmbNamedPipe.java:189)
at net.sourceforge.jtds.jdbc.SharedNamedPipe.<init>(SharedNamedPipe.java:76)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.createNamedPipe(ConnectionJDBC2.java:459)
at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:294)
... 5 more
What is the problem,and how can i resolve it?
thanks.
By the way,this program doesn't work(both on winxp and linux) if i don't use "namedPipe=true"(connection refused).