Discussions

EJB programming & troubleshooting: Remote Connectivity to Sybase Database

  1. Remote Connectivity to Sybase Database (1 messages)

    Sybase-JDBC Guru's,

    I need to connect to a remote Sybase Database using JAVA Application (JDBC). The database is located in a different location and i can ping the server using the IP. Does anyone has a code snippet which helps me to fetch the data from Sybase Database Server. I have less time to investigate, so please provide some code link or similar solution. Appreciate
  2. Hi,
    IT depends which driver you are using.
    I am using Jconnect.
    Code to connect database for jdbc is
    Properties props = new Properties();
       props.put("user", "CDB_GEN"); // user id for the database
      props.put("password", "proximus"); // password for the database
    Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
    String url= "jdbc:sybase:Tds:<ip/host name>:<port at wich the database service is running>";
    con = DriverManager.getConnection(url,props);
    YOu can get the Jconnect driver from the sybase site.

    and if you want to use odbc
    Then
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String url = "Jdbc:Odbc:<dsn name>";
    con = DriverManager.getConnection(url,<userid>, <password>);


    HTH
    Anil