Url format for jtds ?

Hi,

I want connect to my ms sql server database frm java.

i have download the jtds driver and put it on my classpath.

the driver documentation stated the below format :

jdbc:jtds:<server_type>://<server>[:<port>][/<database>][;<property>=<value>[;...]]

wh

so i write my url like this :

url="jdbc:jtds:local://localhost:1433/ ";username="user ";password="password;";

But i get error msg...

java.sql.SQLException: The syntax of the connection URL 'jdbc:jtds:local://localhost:1433/northwind;username=sa;password=pass;' is invalid.

at net.sourceforge.jtds.jdbc.Driver.setupConnectProperties(Driver.java:239)

at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:175)

Can anyone help...?

[802 byte] By [Singama] at [2007-10-2 7:47:29]
# 1
String url = "jdbc:jtds:sqlserver://localhost:1433/northwind;username=user;password=password";
Singama at 2007-7-16 21:34:02 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
See http://jtds.sourceforge.net/faq.html#urlFormatThe server type is either sqlserver or sybase depending on what you are connecting to. But judging from the northwind I would say sqlserver.
Singama at 2007-7-16 21:34:02 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3

After edit the url format i get this error msg:

java.sql.SQLException: Network error IOException: Connection refused: connect

at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:372)

at net.sourceforge.jtds.jdbc.ConnectionJDBC3.<init>(ConnectionJDBC3.java:50)

at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:178)

at java.sql.DriverManager.getConnection(DriverManager.java:525)

at java.sql.DriverManager.getConnection(DriverManager.java:193)

at jdbcApp.dbConn.newCon(dbConn.java:67)

at jdbcApp.test.<init>(test.java:36)

at jdbcApp.test.main(test.java:53)

Caused by: java.net.ConnectException: Connection refused: connect

at java.net.PlainSocketImpl.socketConnect(Native Method)

at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)

at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)

at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)

at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)

at java.net.Socket.connect(Socket.java:507)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:585)

at net.sourceforge.jtds.jdbc.SharedSocket.createSocketForJDBC3(SharedSocket.java:289)

at net.sourceforge.jtds.jdbc.SharedSocket.<init>(SharedSocket.java:250)

at net.sourceforge.jtds.jdbc.ConnectionJDBC2.<init>(ConnectionJDBC2.java:297)

... 7 more

Exception in thread "main" java.lang.NullPointerException

at jdbcApp.dbConn.getResult(dbConn.java:89)

at jdbcApp.test.<init>(test.java:37)

at jdbcApp.test.main(test.java:53)

Java Result: 1

I have checked the port no its 1433 username & password are correct.

and its support tcp/ip connect...

what are the other possibilities....?

Singama at 2007-7-16 21:34:02 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4

Whenever you see this

Caused by: java.net.ConnectException: Connection refused: connect

That means that java could not open a socket to the requested server and port.

So one of the following is true

- the server is not on localhost

- the port is wrong

- the server is not listening on tcp/ip

- there is a firewall blocking you

You say you have checked the first three.. although I would warn you to get sql server to actually listen for tcp requests usually requires a service restart... so baring one of those still being wrong you have a firewall.

M$ has got it in their heads to install firewalls on every PC in a secret way so likely you have a firewall you don't even know about. Anyway pole around on your machine and you will have to open that port or allow Java to connect or whatnot.

Singama at 2007-7-16 21:34:02 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
How to configure the firewall settings...?
Singama at 2007-7-16 21:34:02 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...