Hi everyone,
I am using Ubuntu 7.10, and I have Java and MySQL installed with the command line as follow:

1. sudo apt-get install sun-java6-jdk
2. sudo apt-get install mysql-server

and my JAVA and MySQL are working well, but now I want create connection between JAVA application and MySQL using the JDBC API not using tomcat, but when I run my file, I get the following error:

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at DB.dbConnect(getmySQLConnection.java:23)
at getmySQLConnection.main(getmySQLConnection.java:8)


it is about two days I am searchind on the web, plz some one help me

if you're really spent 2 days searching for an answer to this and haven't found it you're extremely incompetent.
This question must have been asked by kids who don't know what they're doing, how to set a classpath, and how to READ MANUALS a million times.

IOW, Read The F***ing Manual and actually learn Java before you attempt to do things more complicated than printing "Hello World" on the console.

commented: Why waste your time actually criticizing someone for asking a question? +0

You man!!!!!!!!!!!!!!!! after spending about 1 hour and more, instead of posting such stupid words, post the solution, if you can. obviously I don't know, because of this I posted here...

first thanks for replying:

for further info:

1. I download the following file:
mysql-connector-java-5.0.8.tar.gz

2. Then I used the following command:
tar -ztvf mysql-connector-java-5.0.8.tar.gz

3. then I went to opt directory like below:
cd /opt

4. Then I used the following command:
tar -zxvf /home/sherzad/Desktop/mysql-connector-java-5.0.8.tar.gz

5. Then I opened the file like beneath:
gedit ~/.bashrc

6. and finally I added the following two lines:

CLASSPATH=$CLASSPATH:/usr/share/java/mysql.jar
export CLASSPATH

I dont know much of ubuntu, plz be a little in detail, Thanks

finally, I found the solution, just the CLASSPATH must the name of the jar file, not mysql.jar.

Hi Tanha,

Thank you for this posting - I was having the same problem until I realized that mysql is not released with a JDBC driver: as your procedure illustrates, this must be downloaded separately.

Don't let the haters get you down - your post was very useful to me, and I'm sure to others as well.

Don't let the haters get you down - your post was very useful to me, and I'm sure to others as well.

I'm sure that in the six months it has been since they created this thread, they have gotten over any negative comments.

I'm sure that in the six months it has been since they created this thread, they have gotten over any negative comments.

you never know ... maybe he 's the kind of person that keeps a grudge :/

you never know ... maybe he 's the kind of person that keeps a grudge :/

I think the major issue is for those of us finding these threads through Google, we don't want to read someone's rude remark to an honest question. If someone has a solution but would rather just insult the OP, maybe they should go take a dump in their own coffee and drink it. I, on the other hand, would just like to see a solution.

I think the major issue is for those of us finding these threads through Google, we don't want to read someone's rude remark to an honest question. If someone has a solution but would rather just insult the OP, maybe they should go take a dump in their own coffee and drink it. I, on the other hand, would just like to see a solution.

You can
A) have look on setting up environment
B) create new thread and explain in detail what exactly is problem (not knowing how to install, getting some errors, etc)

Thread closed

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.