Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Sunday, February 19, 2012

Help with java connection to MS SQL 2000 with windows integrated security

Hi , I am trying to connect to MS Sql server 2000 from Java (1.4.2 /
1.5 ). I installed my Sql Server(8.00.382) from the one supplied with
VS.NET 2001. When I installed it on my laptop it did not ask me for a
user name and password. After install when I re-started my machine I
see the server started up with a green light. Now when I connect to the
server from VS.NET it works fine. This is because VS uses windows
integrated security. I now need to connect using Java , so I downloaded
the microsoft drivers for SQL2000-JDBC sp3 from the microsoft site. I
added the jar files to my Java project classpath. I manage to register
the driver in java :

Class dbClass = ClassLoader.getSystemClassLoader().

loadClass("com.microsoft.jdbc.sqlserver.SQLServerDriver");

DriverManager.registerDriver((Driver) dbClass.newInstance() );

Connection conn =
DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;_
integrated security=SSPI");

but cannot seem to get a connection as it gives an SQLException saying
that it is unable to connect:

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

I cant seem to figure it out.Can some one help ??

I am a newbie to sqlserver so couldnt quite figure out how to change
admin password or create a new user with the tools provided with this
version of sql (SQL Server Desktop Engine).

Any help will be appreciated.

EbbyHi ... I also tried the following connection string which I made after
looking at other peoples problems.

jdbc:microsoft:sqlserver://EBBY/VSdotNET:1433;DatabaseName=Ebby");

where EBBY is the server name
VSdotNET the instance name
Ebby the database name|||Hi

You may want to check out
http://support.microsoft.com/defaul...kb;en-us;313100

The following would imply that a names instance would require a different
port (or possibly an alias) to connect
http://support.microsoft.com/defaul...kb;en-us;313225

John
<ebrahimbandookwala@.gmail.com> wrote in message
news:1111297471.633617.217830@.g14g2000cwa.googlegr oups.com...
> Hi ... I also tried the following connection string which I made after
> looking at other peoples problems.
> jdbc:microsoft:sqlserver://EBBY/VSdotNET:1433;DatabaseName=Ebby");
> where EBBY is the server name
> VSdotNET the instance name
> Ebby the database name|||(ebrahimbandookwala@.gmail.com) writes:
> Hi , I am trying to connect to MS Sql server 2000 from Java (1.4.2 /
> 1.5 ). I installed my Sql Server(8.00.382) from the one supplied with
> VS.NET 2001.

8.00.382 is SQL 2000 SP1. The current service pack of SQL 2000 is SP3 (and
SP4 is in beta). I strongly recommend you to upgrade to SP3, as SP3
has a fix for the Slammer worm which could attack your SQL Server if
you were to expose it on the Internet.

> Connection conn =
> DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;_
> integrated security=SSPI");

1433 is normally the port for the default instance, and apparently you have
a named instance. Check out the links posted by John, and see if they help.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp