You are not logged in.
Pages: 1
i've followed th wiki
https://wiki.archlinux.org/index.php/JDBC_and_MySQL
but when i do java DBDemo
this is the output:
java DBDemo
com.mysql.jdbc.Driver
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at DBDemo.main(DBDemo.java:18)
instead when i tried
@arch mysql-connector-java-5.1.28]$ sudo x=mysql-connector-java-mysql-connector-java-5.1.28-bin.jar; install -D $x /opt/java/jre/lib/ext/${x##*/}
output:
@arch mysql-connector-java-5.1.28]$ sudo x=mysql-connector-java-mysql-connector-java-5.1.28-bin.jar; install -D $x /opt/java/jre/lib/ext/${x##*/}
usage: sudo -h | -K | -k | -V
usage: sudo -v [-AknS] [-g group] [-h host] [-p prompt] [-u user]
usage: sudo -l [-AknS] [-g group] [-h host] [-p prompt] [-U user] [-u user] [command]
usage: sudo [-AbEHknPS] [-C num] [-g group] [-h host] [-p prompt] [-u user] [VAR=value] [-i|-s] [<command>]
usage: sudo -e [-AknS] [-C num] [-g group] [-h host] [-p prompt] [-u user] file ...
install: missing destination file operand after '/opt/java/jre/lib/ext/'
Try 'install --help' for more information.
Last edited by otto88 (2014-01-10 21:53:14)
Offline
please, is urgent
Offline
sudo x=mysql-connector-java-mysql-connector-java-5.1.28-bin.jar; install -D $x /opt/java/jre/lib/ext/${x##*/}
su
# x=mysql-connector-java-*-bin.jar; install -D $x /opt/java/jre/lib/ext/${x##*/}
Offline
thanks, ok i've done but this is the output:
@arch ~]$ java DBDemo
com.mysql.jdbc.Driver
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at DBDemo.main(DBDemo.java:18)
Offline
what can i try to fix it ?
Offline
I'm not sure if this is too late to help you, but you might try adding /opt/java/jre/lib/ext/ to your classpath. You can do this temporarily by invoking your test program like this:
java -classpath ".:/opt/java/jre/lib/ext/mysql-connector-java-mysql-connector-java-5.1.28-bin.jar" DBDemo
. The problem is that your Java Runtime Environment can't find the JDBC driver, probably because it doesn't know to look for it in the directory where you installed it, but you can tell it where to look using the -classpath option. Just don't forget to tell it also to look in ".", that is, the current working directory, because otherwise it won't find DBDemo.class.
Offline
I'm not sure if this is too late to help you, but you might try adding /opt/java/jre/lib/ext/ to your classpath. You can do this temporarily by invoking your test program like this:
java -classpath ".:/opt/java/jre/lib/ext/mysql-connector-java-mysql-connector-java-5.1.28-bin.jar" DBDemo
. The problem is that your Java Runtime Environment can't find the JDBC driver, probably because it doesn't know to look for it in the directory where you installed it, but you can tell it where to look using the -classpath option. Just don't forget to tell it also to look in ".", that is, the current working directory, because otherwise it won't find DBDemo.class.
i try to run
java -classpath ".:/dati/Documenti/-INGSW2/mysql-connector-java-5.1.26" DBDemo
com.mysql.jdbc.Driver
Exception in thread "main" java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at DBDemo.main(DBDemo.java:18)
Offline
java -classpath ".:/dati/Documenti/-INGSW2/mysql-connector-java-5.1.26" DBDemo
Did you unpack the jar archive? If you still have the mysql-connector-java.5.1.26-bin.jar file, you can include the original .jar file itself in the classpath, as opposed to the directory. The important concept is that "ClassNotFoundException" means that the class you want to use is not in your classpath, which means you either need to change the classpath to point to a place that has the class, or put the class into your classpath.
Offline
Pages: 1