  | | | Subject: problem to solve classpath | Subject: problem to solve classpath 2007-11-09 - By Michel Maria-Sube
Back Hello,
I'm working under UNIX Suse 10.2 and using version 3.1.14 of jdbc; my application is apparently unable to find path of classes defined in the jdbc archive. At the beginning, application try to load driver class as follows:
import javax.swing.*; import java.lang.*; import java.net.*; import java.awt.*; import java.awt.event.*; import javax.swing.border.*; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.io.*; import java.util.Vector;
...
public class <the_main_class> { ....
public void connectDB( String DBName, String user, String passwd ) { ... try { Class.forName("com.mysql.jdbc.Driver").newInstance(); } catch (ClassNotFoundException cnfe) { System.out.println("\nClassNotFoundException occured"); System.out.println("connection with the DB is not possible"); System.exit(ERROR); } ..... } //end of method
.... public static void main( String args[] ) { ........ } } //end of main class
at execution, piece of code defined in the method corpse:
Class.forName("com.mysql.jdbc.Driver").newInstance();
create exception: ClassNotFoundException
Before compiling, I set CLASSPATH variable as:
export CLASSPATH='/usr/share/jdbc/mysql-connector-java-3 (See http://ava-3.ora-code.com).1.14-bin.jar'
then I compile with standard command:
javac *.java
and create jar executable with command:
jar cvfm runme.jar ./META-INF/MANIFEST.MF *.class
The sole way i found to solve path of Driver class is to put directly in the jar executable content of class files, i.e to extract the com directory (under current location) from jdbc archive and then update runme.jar by doing:
jar uvf runme.jar com
but this solution is unacceptable; I precise too that when I was working previously under another linux distro (mandrake10) I didn't encounter this problem, classes where found just by specifying classpath value; this seems rather uncreadible even for me but maybe have i forgot or uncorrectly set something...well suggestions are welcome...Thank you in advance
Michel
-- MySQL Java Mailing List For list archives: http://lists.mysql.com/java To unsubscribe: http://lists.mysql.com/java?unsub=mysql@(protected)
|
|
 |