Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC connection to SQL Server 2000

 
Laurent Quenon
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
When I try to connect to a SQL Server database installed locally on my computer with the piece of code you can find below, I always receive a SQLException ("[Microsoft][SQLServer 2000 Driver for JDBC]Connection reset")
Here is the code, it seems that the exception is thrown by the DriverManager.getConnection.
...
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabasName=VolleyManagement_Draft");
return con;
Can someone help me?
Thx a lot.
 
Joe Ess
Bartender
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could it be that "DatabasName" is misspelled?
 
Laurent Quenon
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx for your valuable remark, but it's not that.
I probably made a mistake during my several tries, but now it's corrected and it's still the same error.
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection con = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=VolleyManagement_Draft");
return con;
Any ideas?
 
Joe Ess
Bartender
Posts: 9320
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Laurent Quenon:
Thx for your valuable remark, but it's not that.

I am a master of the obvious. How about using the DriverManager.getConnection(url, user, pwd) method, using a username and a password? I believe the default user for SQL Server is "sa" and a blank password.
 
dee kal
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try this...I think it will work.
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
url="jdbc:microsoft:sqlserver://OM-KL9W08EZQ2ZX:1433;DatabaseName=emp";
userName="sa";
pwd="sa";
Connection connection=DriverManager.getConnection(url,userName,pwd);
Bye.
 
Laurent Quenon
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot... indeed it was better, because now my program is at least connecting, but now I receive another exception "The user is not associated with a secure connection to SQL Server". The user I'm using for that connection is "SA" so I really don't understand.
Any ideas...
 
Christopher Zinn
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've run into this exact problem also.
On our server, the issue was the security mode.
It was set for "Windows Only", we changed
it to "SQL Server and Windows"; which enabled us to log in using the
"sa" account (and other accounts also).
The setting can be found by going into the Enterprise Manager,
properties on the server and the security tab.

- Chris
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic