java jdbc connection to sql server

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

  1. macrumors member

    Joined:
    Mar 26, 2007
    #1
    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...
     
  2. macrumors 6502a

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #2
    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
     
  3. thread starter macrumors member

    Joined:
    Mar 26, 2007
    #3
    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 emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #4
    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. thread starter macrumors member

    Joined:
    Mar 26, 2007
    #5
    ping

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

    Joined:
    Sep 3, 2005
    Location:
    Cramlington, UK
    #6
    Thanks for the info… much appreciated!

    b e n
     
  7. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #7
    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. thread starter macrumors member

    Joined:
    Mar 26, 2007
    #8
    thanks

    thank you very much for your suggestions...
     

Share This Page