Hi, I wnat to connect to mySQL fromo
Java, I followed all the instructions from the mySql web page, yet I havent been able to do it, when I compile the java progrm I keep getting class not found exceptions, I am using Fedora Core and Java was already installed-well I chose to install it when I installed the operating system, the point is that the paths are all assigned by he system not by me.
WHat can I do?, Ive been trying over andover again with no results, hopefully somebody can help, I tried to include all the configuration in this email
thank you
my java program is the following:
t.java
----------
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class t {
public static void main (
String[] args) {
System.out.println("Hello, world!\n");
Class.forName("com.mysql.jdbc.Driver");
}
}
-------------
when I javac t.java
I have the following error
4. ERROR in t.java
(at line 11)
Class.forName("com.mysql.jdbc.Driver");
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Unhandled exception type ClassNotFoundException
-----
when I comment out the Class.forName the hello world rogram runs fine
---------------------------
# System-wide Java configuration file -*- sh -*-
#
# JPackage Project <
http://www.jpackage.org/>
# Location of jar files on the system
JAVA_LIBDIR=/usr/share/java
# Location of arch-specific jar files on the system
JNI_LIBDIR=/usr/lib/java
# Root of all JVM installations
JVM_ROOT=/usr/lib/jvm
# You can define a system-wide JVM root here if you're not using the default one#JAVA_HOME=$JVM_ROOT/java-gcj
# Options to pass to the java interpreter
JAVACMD_OPTS=
~
--------------------
[root@localhost
test]# echo $PATH
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin
-------------------
echo $JAVA_HOME
--------------
ls /usr/share java*
java
java-1.3.0
java-1.4.0
java-1.4.1
java-1.4.2
java-1.5.0
javadoc
java-ext
java-utils
-------
mysql-connector-java-3.1.13-bin.jar is under
/usr/share/java
---------
in /etc/profile I have:
export CLASSPATH=$CLASSPATH:/usr/share/java/mysql-connector-java-3.1.13-bin.jar
--------
in /root/.bash_profile i have
CLASSPATH=/usr/share/java/mysql-connector-java-3.1.13-bin.jar:/usr/lib/java-ext/mysql-connector/mysql-connector-java-3.1.13-bin.jar
export CLASSPATH
----------------
when I echo $PATH i have
/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin