• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

connect to SQLServer Database in XP?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you tell more details?What should I do to set the authentication?
 
Paul Sturrock
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Configure the settings via the security tab of the properties for your SQL Server instance.
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic