free TDS with sql server problem

hi

has any one used free tds i am facing problem using it.

in my code at line

Connection con=DriverManager.getConnection("jdbc:freetds:sqlserver://server1/Northwind;user=sa;password=;");

i get

Exception- java.lang.NullPointerException

java.sql.SQLException

can anyone help me with this

i have set classpath for freetds_jdbc.jar

[398 byte] By [parul_patidar] at [2007-9-26 4:17:13]
# 1
Is it just a typo or have you really missed specifying a value for password at the end of your JDBC URL ?And, I don't think you have to end the JDBC URL with a semicolon.
neville_sequeira at 2007-6-29 13:27:37 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

the syntax you want to successfully achieve a connection is to:

String url = "jdbc:freetds:sqlserver://server1/Northwind";

Connection con = DriverManager.getConnection(url, "sa", "");

if sa was a String variable then you should leave the quotes off-->.., sa, "");

Jamie

jlrober at 2007-6-29 13:27:37 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
no i deliberatly missed it as there is no password for database
parul_patidar at 2007-6-29 13:27:37 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
problem is still there i made chanhges now i am usingConnection con=DriverManager.getConnection("jdbc:freetds:sqlserver://bhai/Northwind","sa","");but still same problem
parul_patidar at 2007-6-29 13:27:37 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
Are you sure the null pointer exception is occuring in the connection line?
jschell at 2007-6-29 13:27:37 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6
Hi, my quess would be that DriverManager is null and that you've not caught exceptions thrown by Class.forName(driver);
davejenk at 2007-6-29 13:27:37 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7

i am sending complete code i tried

when i run it only a gets printed and a null pointer exception is thrown please try to run this code if u have freeTds jdbc driver

it will be helpful if u can send jar file for freeTds driver

my mail address is parul_patidar@yahoo.com

import java.sql.*;

public class FreeTDSTest

{

public static void main(String a[])

{

try

{

Class.forName("com.internetcds.jdbc.tds.Driver").newInstance();

System.out.println("a");

Connection con=DriverManager.getConnection("jdbc:freetds:sqlserver://bhai/Northwind","sa","");

System.out.println("b");

Statement s1=con.createStatement();

System.out.println("c");

ResultSet rs=s1.executeQuery("Select * from Region");

System.out.println("d");

ResultSetMetaData rsmd=rs.getMetaData();

System.out.println("e");

while(rs.next())

{

System.out.println(rs.getString(1));

}

System.out.println("f");

}catch(ClassNotFoundException cnfe ){System.out.println(cnfe);}

catch(IllegalAccessException ie){System.out.println(ie);}

catch(InstantiationException ine){System.out.println(ine);}

catch(SQLException sqle){System.out.println(sqle);}

}

}

parul_patidar at 2007-6-29 13:27:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8

In your catch blocks add the method printStackTrace() to each exception. So

catch(ClassNotFoundException cnfe )

{

System.out.println(cnfe);

cnfe.printStackTrace();

}

In your main routine (or at least outside of where you have the current try/catch) add the following try catch

main(...)

{

try

{

// all the rest of the code

}

catch(Throwable e)

{

e.printStackTrace();

}

}

.

This will identify the exact line that the error is occurring on.

jschell at 2007-6-29 13:27:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 9

I tried what u suggested

it is giving following error

java.sql.SQLException: Network error- Connection refused: no further information

at com.internetcds.jdbc.tds.Constructors.newConnection(Constructors.java:269)

at com.internetcds.jdbc.tds.Driver.connect(Driver.java:282)

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

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

at FreeTDSTest.main(FreeTDSTest.java:13)

java.sql.SQLException: Network error- Connection refused: no further information

it is giving network error since i changed machine. earlier it used to give null pointer exception

on both machines JdbcOdbcDriver works correctly

parul_patidar at 2007-6-29 13:27:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 10
also can u tell me whether i can connect to a sql server database installed on web server from a client machine using JdbcOdbcDriver
parul_patidar at 2007-6-29 13:27:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 11
Hi Parul,I use freeTDS and ran into a NullPointerException in the first place. I could fix this by switching back from JDK 1.3 to JDK 1.2.2. You should try if this helps...Regards Eckhard
eckhards at 2007-6-29 13:27:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 12

>also can u tell me whether i can connect to a sql

> server database installed on web server from a client machine using JdbcOdbcDriver

The client machine would have to have the MS SQL ODBC driver on it. This has nothing to do with java. If it isn't there, then you can't use the bridge to connect.

You also have to mess around with the security a bit. That is documented in previous posts.

jschell at 2007-6-29 13:27:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 13
can u tell me about security issues i will have to deal with
parul_patidar at 2007-6-29 13:27:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 14
Hi,But I'm wondering how u can use freeTds in NT environment?
wunixme at 2007-6-29 13:27:38 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...