Posts Tagged ‘jdbc’

Installing the jconnect for Sybase ASE.

March 24th, 2011 No comments

1. Install the Java Runtime environment or Install the JDK from

2. Set the PATH environment variable for Java compiler and interpreter as

export PATH

3. Download the jconnect(Sybase Driver) from Sybase and untar/unzip the package from

4. You need to define two env variable CLASSPATH & JDBC_HOME

i)Set the JDBC_HOME as
[sybase@localhost jConnect-6_0]$ JDBC_HOME=”/home/sybase/15.5/jConnect-6_0″
[sybase@localhost jConnect-6_0]$ export JDBC_HOME
[sybase@localhost jConnect-6_0]$ echo $JDBC_HOME

ii) Set the CLASSPATH as
[sybase@localhost jConnect-6_0]$CLASSPATH=”$JDBC_HOME/classes”:”/home/sybase/15.5/jConnect-6_0/classes/jconn3.jar “:.
[sybase@localhost jConnect-6_0]$ export CLASSPATH
[sybase@localhost jConnect-6_0]$ echo $CLASSPATH

5. Install the Jconnect stored procs and tables :

For jConnect to function properly, you must install stored procedures and tables on the Adaptive Server Enterprise or ASA.

Go the $JDBC_HOME/classes
java IsqlApp -U sa -P -S jdbc:sybase:Tds:localhost.localdomain:5000 -I $JDBC_HOME/sp/sql_server15.0.sql -c go

6. If installation is successful, you need to test the installation

For testing you can check using following Applet : run from $JDBC_HOME
java sample2.SybSample Version
If everything is fine, you can get the jconnect version in output window.

7. Testing Java connectivity with Sybase ASE
[sybase@localhost ~]$ cat
import java.sql.* ;
public class JdbcTest
public static void main( String args[] )
Class.forName( “com.sybase.jdbc3.jdbc.SybDriver” ) ;
Connection conn = DriverManager.getConnection( “jdbc:sybase:Tds:localhost.localdomain:5000”, “sa”, “”) ;
Statement stmt = conn.createStatement() ;
ResultSet rs = stmt.executeQuery( “SELECT * FROM master..sysdatabases” ) ;
while( )
System.out.println( rs.getString(1) ) ;
rs.close() ;
stmt.close() ;
conn.close() ;
catch( Exception e )
{ System.out.println( e ) ; }

i)Compile the code
[sybase@localhost ~]$ javac

ii)Test your code
[sybase@localhost ~]$ java JdbcTest