Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ashokformac

macrumors member
Original poster
Mar 26, 2007
34
0
Hi , i am new to mac. i am using java jdbc connection to access the data in ms sql server.I am using jTDS jdbc driver and mac 10.4 . I am not able to connect to sql server .
following are the lines i used for connection ..

Class.forName("net.sourceforge.jtds.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:jtds:sqlserver://172.16.4.59/iarchivev2;user=iarchiveuser;password=system");

but connection was not establishing...
it say unable to connect to remote host..

can any one help me to solve this problem...
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Hi

Don't you have to call newInstance() on the class?

eg

Class.forName( "com.mysql.jdbc.Driver" ).newInstance() ;

Well that's what I do at any rate.


b e n
 

ashokformac

macrumors member
Original poster
Mar 26, 2007
34
0
hi thank you for your reply,

still it is not working .. the following error occurs

Network error IOException: Operation timed out

can any one help me ?
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
Hi

Don't you have to call newInstance() on the class?

eg

Class.forName( "com.mysql.jdbc.Driver" ).newInstance() ;

Well that's what I do at any rate.


b e n

You don't have to call newInstance(). I use JDBC a lot at work connecting to Sybase enterprise database servers. We don't call newInstance(). When you ask for a connection the JDBC libraries automatically create an instance for you if needed. You simply have to ensure that the class has been loaded into the current JVM session. Which is what Class.forName does.

As for why it does not work: did you read and consider the error? It's not apparently a code problem. It is telling you that it did not receive a response from the server specified. Can you ping that IP address?
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
You don't have to call newInstance(). I use JDBC a lot at work connecting to Sybase enterprise database servers. We don't call newInstance(). When you ask for a connection the JDBC libraries automatically create an instance for you if needed. You simply have to ensure that the class has been loaded into the current JVM session. Which is what Class.forName does.

Thanks for the info… much appreciated!

b e n
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
no i am not able to connect using ping....

Well if you can't ping it (this is not connecting, simply sending a packet and seeing if the address replies) then you cannot see that machine at a network level. Either the address does not exist or there are firewalls between you and it that are preventing you from talking to it. Is it a Uni server and you are outside the Uni network perhaps?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.