To connect Sybase using JDBC jconn{version}.jar should be there in your classpath. You could Google and download this jar and include in your class path.

Connect Sybase using JDBC sample java program:

package com.javahonk;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class GetSybaseConnection {

	public static void main(String[] args) {

	Connection connection = null;

	try {
	// Register JDBC Driver
	Class.forName("com.sybase.jdbc.SybDriver");
	// Open connection
	connection = DriverManager.getConnection(
			"jdbc:sybase:Tds:hostname: "
			+ "port Number/databaseName", 
			"user_id", "password");
	if (null != connection) {
		System.out.println("Sucessfully "
				+ "connected to Sybase database!!!");
	} else {
		System.out.println("Connection "
				+ "to Sybase database failed!!!");
	}

	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		try {
			if (connection != null) {
				connection.close();
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}

	}

}

 

Output:

Connect Sybase using JDBC

That’s it for connect Sybase using JDBC

Leave a Reply

Your email address will not be published. Required fields are marked *