This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes JDBC connection to SQL Server 2000 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC connection to SQL Server 2000" Watch "JDBC connection to SQL Server 2000" New topic
Author

JDBC connection to SQL Server 2000

Laurent Quenon
Greenhorn

Joined: Dec 09, 2003
Posts: 11
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

Joined: Oct 29, 2001
Posts: 8843
    
    7

Could it be that "DatabasName" is misspelled?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Laurent Quenon
Greenhorn

Joined: Dec 09, 2003
Posts: 11
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

Joined: Oct 29, 2001
Posts: 8843
    
    7

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

Joined: Oct 08, 2003
Posts: 10
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

Joined: Dec 09, 2003
Posts: 11
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

Joined: Nov 03, 2003
Posts: 13
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: JDBC connection to SQL Server 2000
 
Similar Threads
Where should IP address in Connection?
SQLException: The Network Adapter could not establish the connection?? what it means
java.sql.SQLException: No suitable driver
connection object question
How to connect to SQL Server 2000 ? please help !!!