• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connect to SQLServer Database in XP?

 
yi qian
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it very difficult to connect to SQLServer Database using JDBC Driver in XP operation system?Today I try to connect,but I failed.I registed a user and I give all the rights to it.But I use this user to connect.I failed.
The part of my code is:
try {
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
System.out.println("success");
}
catch (Exception e) {
System.out.println("fail");
}
Connection con=null;
Statement stat=null;
ResultSet rs;
try{
String URL="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=DangAnGuan";
con=DriverManager.getConnection(URL,"king","2812986");
stat = con.createStatement();

}catch(SQLException e)
{
System.out.println("There is a Problem");
e.printStackTrace();
}
The fail tips are:
success

java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error establishing socket.

at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)

at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)

at com.microsoft.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)

at com.microsoft.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)

at com.microsoft.jdbc.base.BaseConnection.getNewImplConnection(Unknown Source)

at com.microsoft.jdbc.base.BaseConnection.open(Unknown Source)

at com.microsoft.jdbc.base.BaseDriver.connect(Unknown Source)

at java.sql.DriverManager.getConnection(DriverManager.java:512)

at java.sql.DriverManager.getConnection(DriverManager.java:171)

at com.heaton.bot.SpiderWorker.SaveBulletin(SpiderWorker.java:237)

at com.heaton.bot.SpiderWorker.processBulletin(SpiderWorker.java:112)

at com.heaton.bot.SpiderWorker.processWorkload(SpiderWorker.java:41)

at com.heaton.bot.SpiderWorker.run(SpiderWorker.java:32)

There is a problem.
What's wrong?I don't know.Could you tell me?Thank you!
[ November 17, 2005: Message edited by: Bear Bibeault ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of authentication are you using? For Microsoft's SQL Server driver it has to be "Windows and SQL Server" authentication.
 
yi qian
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you tell more details?What should I do to set the authentication?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Change it for your instance of SQL Server, which you can do through the "Security" tab of the properties for the server.

(If that last sentence didn't make sense to you the documentation should make it clearer).
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Configure the settings via the security tab of the properties for your SQL Server instance.
 
Paul Clapham
Sheriff
Posts: 21113
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error message "Error establishing socket" suggests to me that the problem is something to do with the network and that it hasn't got to the authentication stage yet.
 
todd runstein
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another suggestion is to use another driver. The one from microsoft sucks. Try JTDS (jtds.sourceforge.net). If nothing else, it may provide an error message that is actually helpful.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic