I want to connect remote Sybase
from my Java
code written in NetBeans
. So far I have prepared a code as below:
public static void connect()
{
String host = "192.168.150.11";
String url = "jdbc:sybase:Tds:"+host+":4100";
String username = "sa";
String password ="";
SybDriver sybDriver = null;
Connection conn;
try
{
sybDriver=(SybDriver)Class.forName("com.sybase.jdbc3.jdbc.SybDriver").newInstance();
System.out.println("Driver Loaded");
conn = DriverManager.getConnection(url,username,password);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from zxdbl_888..account_0");
rs.next();
System.out.println(rs.getString(2));
}
catch (InstantiationException ex)
{
Logger.getLogger(Offline_charge.class.getName()).log(Level.SEVERE, null, ex);
}
catch (IllegalAccessException ex)
{
Logger.getLogger(Offline_charge.class.getName()).log(Level.SEVERE, null, ex);
}
catch (ClassNotFoundException ex)
{
Logger.getLogger(Offline_charge.class.getName()).log(Level.SEVERE, null, ex);
}
catch (SQLException ex)
{
Logger.getLogger(Offline_charge.class.getName()).log(Level.SEVERE, null, ex);
}
}
and the error I got is:
java.lang.ClassNotFoundException: com.sybase.jdbc3.jdbc.SybDriver
I have loaded jconn3.jar
library.
Use the Connect to Sybase dialog box to connect to the Sybase Adaptive Server Enterprise (ASE) instance that you want to migrate. To access this dialog box, on the File menu, select Connect to Sybase. If you have previously connected, the command is Reconnect to Sybase.
Connecting to Sybase via JDBC Then select the JDBC (JConnect . . .) connection type from the connection type list. Enter any login information if applicable, and then enter the host or ip address of the Sybase server, and the port Sybase is listening on. Next, enter the name of the Sybase database to connect to.
Install the Sybase
drivers via a Java application.
Sybase: Installing jConnect for JDBC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With