This is a java code snippet which can be used to connect Sybase database using
JDBC driver (SybDriver). Jconnect is the name of the package which contains the
JDBC driver. You can use the jdbc driver provided by Sybase. Using Jconnect we
are going to connect a sybase database
import java.sql.*; import com.sybase.jdbcx.*; public class SybaseConnectivity { Connection con = null; Statement stmt = null; SybDriver sybDriver = null; public void makeConnection() throws Exception { // try { sybDriver = (SybDriver) Class.forName( "com.sybase.jdbc3.jdbc.SybDriver").newInstance(); System.out.println("Driver loaded"); con = DriverManager .getConnection("jdbc:sybase:Tds:<server ip><port>", "username", "password"); Statement stmt = con.createStatement(); // Execute the query ResultSet rs = stmt.executeQuery("select * from test"); // Loop through the result set while (rs.next()) { System.out.println(rs.getString(1)); } // Close the result set, statement and the connection rs.close(); stmt.close(); con.close(); }// catch(Exception e) { // System.out.println("Error is "+e.getMessage()); } } public static void main(String args[]) throws Exception { SybaseConnectivity sc = new SybaseConnectivity(); sc.makeConnection(); } }