views:

2076

answers:

2

I'm trying to connect to a MS SQL Server 2005 Express database that is running on the local host from a java program.

I have tried the same connect URL (below) that I used on another system (same jave code) that was running MS SQL Server 2000. But that does not work.

jdbc:jtds:sqlserver://127.0.0.1:1433/Finance

Any ideas?

+3  A: 

Are you sure it is the correct instance? SQL Express tends to install as named instance, like "localhost\SQLExpress", instead of a standard instance. So it would be something like:

jdbc:jtds:sqlserver://127.0.0.1:1433/Finance;instance=<instance_name>

If this doesn't work, try dropping the instance name, and changing the port to the port used by the named instance:

jdbc:jtds:sqlserver://127.0.0.1:<instance_port>/Finance

Else try to check your connectivity through OSQL.exe tool first. You can also check the jTDS FAQ on this.

MicSim
+2  A: 

I would suggest MicSim's url:

jdbc:jtds:sqlserver://localhost/Finance;instance=sqlexpress

Check this for jTDS Url Info.

This also has some interesting information to help troubleshoot jtds to sql express sorts of problems.

Good luck. Let us know how it goes.

ecounysis
Thanks for the feedback. This is the first time I am working with SQLServer Express and I am finding it significantly different to SQLServer. I still cant connect properly, but it is now down to user permissions not the URL. I'll get back to it as soon as I get home (it is a home system I am working on).
Ron Tuffin