aspose file tools*
The moose likes JDBC and the fly likes JDBC Sybase Driver problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC Sybase Driver problems" Watch "JDBC Sybase Driver problems" New topic
Author

JDBC Sybase Driver problems

Sri Yamujala
Greenhorn

Joined: Dec 07, 2000
Posts: 18
Hi guys,
I've just started playing around with JDBC. Consider me a novice programmer in JDBC. I've a Sybase database - version 11.5 and am running JDK1.3. I'm trying to use jConnect5.2 to connect to Sybase. I've installed
Java in /usr/java
jConnect-5_2 in /usr/sybase/jConnect-5_2
and have the set the environment variables as
$JDBC_HOME=/usr/sybase/jConnect-5_2
$JAVA_HOME=/usr/java
$CLASSPATH=/usr/sybase/jConnect-5_2/classes/jconn2.jar
m-atl10b is my host name and 4100 is the port number that sybase data server can be accessed from.
I've the following source code in Test.java
import java.sql.* ;
import java.sql.* ;
public class Test{
public static void main( String[] args ){
Class.forName( "com.sybase.jdbc2.jdbc.SybDriver" ).newInstance() ;
String url = "jdbc:sybase:Tds:m-atl10b:4100" ;
Connection con = DriverManager.getConnection( url, "srmuser", "srmuser" ) ;
Statement stmt = con.createStatement() ;
String query = "select Msgs from spr_NodeDailyStats" ;
ResultSet rs = stmt.executeQuery( query ) ;
while ( rs.next() )
{
int s = rs.getInt( "Msgs" ) ;
System.out.println( s ) ;
}
}
}
When I try to compile the above code, it compiles fine and when I try to run it, I get the following error:
Class Not Found Exception: com.sybase.jdbc2.jdbc.SybDriver
SQL Exception: No suitable driver
Could any one of you please explain where I'm making a mistake.
Appreciate it.
Thanks,
Sri


Sri
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Looks like you're doing the correct thing.
Try dumping the jconn2.jar into winzip and see if you can locate the com.sybase.jdbc2.jdbc.SybDriver.class file. Sometime vendors change the file name or package without updating the documentation which is really infuriating.
Good luck,
-Peter
Ps. If you find the solution, come back and let us know.
Sri Yamujala
Greenhorn

Joined: Dec 07, 2000
Posts: 18
Thats a good idea, Peter. I just tried going through the jconn2.jar file and it does have the SybDriver.class file

And even the entire path com.sybase.jdbc2.jdbc exists in which the SybDriver.class file is there.
Does it have anything to do with the CLASSPATH? but, the CLASSPATH already points to the /usr/sybase/jConnect-5_2/classes/jconn2.jar
Any ideas???
Thanks
Sri
Peter Tran
Bartender

Joined: Jan 02, 2001
Posts: 783
Sri,
Try using the -cp or -classpath when you invoke the JVM.
e.g.
java -cp /usr/sybase/jConnect-5_2/classes/jconn2.jar Test
If you're on UNIX, make sure you have access to the directory. Copy the jar file to a directory you know you have access to and see if that works.
e.g.
java -cp /home/sri/Test/jconn2.jar Test
-Peter
Sri Yamujala
Greenhorn

Joined: Dec 07, 2000
Posts: 18
Thanks, Peter. That worked.
Appreciate your help.
Thanks,
Sri
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC Sybase Driver problems