java jdbc connection to sql server

Discussion in 'Mac Programming' started by ashokformac, Mar 26, 2007.

  1. macrumors member

    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 ..

    Connection connection = DriverManager.getConnection("jdbc:jtds:sqlserver://;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...
  2. macrumors 6502a


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


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

    Well that's what I do at any rate.

    b e n
  3. macrumors member

    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 ?
  4. Moderator


    Staff Member

    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?
  5. macrumors member


    no i am not able to connect using ping....
  6. macrumors 6502a

    Thanks for the info… much appreciated!

    b e n
  7. Moderator


    Staff Member

    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?
  8. macrumors member


    thank you very much for your suggestions...

Share This Page