Reputation: 11
Firstly I would like to say that I'm new to Java programming and Sybase.
I have a problem with connection to Sybase database.
To establish the connection I have done:
Installation of jdbc driver for advantage db;
Set environment variable named CLASSPATH with url value to adsjdbc.jar (I installed jdbc drivers in c:\AdvJDBC so the path is c:\AdvJDBC\JDBC\adsjdbc.jar );
Then I'm tried to import drivers in my code:
public class SybaseCon {
public static void main(String[] args){
Class.forName("com.extendedsystems.jdbc.advantage.ADSDriver");
}
And I'm getting an error:
Exception in thread "main" java.lang.ClassNotFoundException: com.extendedsystems.jdbc.advantage.ADSDriver
I have searched for the solution in advantage jdbc driver help, but I found nothing that could resolve my problem.
Workaround:
My Java version: jdk1.7.0_03
Advantage file db: 11.0
Advantage jdbc driver: 11.0
Upvotes: 1
Views: 2078
Reputation: 30088
First, make sure that your CLASSPATH variable is actually set in the environment that you think it is.
Typically, in Windows, if you set the environment variable in the system settings, open command windows (and your open IDE) won't see the setting. You have to close and re-open them for it to take effect.
Try adding this to your code, just before the Class.forName line:
System.out.println(System.getProperty("java.class.path"));
It will show you the classpath that your application is actually using.
Second, you'll probably have a much easier time if you specify the classpath using java's preferred path notation, which happens to align with unix/linux format - using forward slashes. Try using
java -cp /AdvJDBC/JDBC/adsjdbc.jar
Upvotes: 1