| Author |
connect to SQLServer Database in XP?
|
yi qian
Greenhorn
Joined: Nov 17, 2005
Posts: 4
|
|
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
Joined: Apr 14, 2004
Posts: 10336
|
|
|
What kind of authentication are you using? For Microsoft's SQL Server driver it has to be "Windows and SQL Server" authentication.
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
yi qian
Greenhorn
Joined: Nov 17, 2005
Posts: 4
|
|
|
Could you tell more details?What should I do to set the authentication?
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
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
Joined: Apr 14, 2004
Posts: 10336
|
|
|
Configure the settings via the security tab of the properties for your SQL Server instance.
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16487
|
|
|
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
Joined: Feb 15, 2005
Posts: 64
|
|
|
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.
|
 |
 |
|
|
subject: connect to SQLServer Database in XP?
|
|
|