• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

sql connection with java

 
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've formatted my linux machine.After that I have downloaded mysql-connector-java-3.0.10-stable.tar.gz.I've put java in the path:usr/share/java.Inside this i am having jre.I dont have jdk.now when i am running a program,it shows the following error.where should i put mysql jar file.Am i going correct?
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver not found in [file:/usr/share/java/libgcj-3.4.3.jar, file:./, core:/]
at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at gnu.gcj.runtime.VMClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.5.0.0)
at _Jv_FindClass(_Jv_Utf8Const, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at Connect1.main(java.lang.String[]) (Unknown Source)
Thanks.
 
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by preethi Ayyappan:
I've formatted my linux machine.After that I have downloaded mysql-connector-java-3.0.10-stable.tar.gz.I've put java in the path:usr/share/java.Inside this i am having jre.I dont have jdk.now when i am running a program,it shows the following error.where should i put mysql jar file.Am i going correct?
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver not found in [file:/usr/share/java/libgcj-3.4.3.jar, file:./, core:/]
at java.net.URLClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at gnu.gcj.runtime.VMClassLoader.findClass(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at java.lang.ClassLoader.loadClass(java.lang.String, boolean) (/usr/lib/libgcj.so.5.0.0)
at _Jv_FindClass(_Jv_Utf8Const, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String, boolean, java.lang.ClassLoader) (/usr/lib/libgcj.so.5.0.0)
at java.lang.Class.forName(java.lang.String) (/usr/lib/libgcj.so.5.0.0)
at Connect1.main(java.lang.String[]) (Unknown Source)
Thanks.





Better you put it inside

usr/share/java
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your reply.I've put the mysql-connector-java-3.0.10-stable.tar.gz,mysql-connector-java-3.0.10-stable-bin.jar
inside usr/share/java.Now also its showing the same error
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
First of all, the .tar.gz file is an archive file. You need to unpack it with tar:

tar xf mysql-connector-java-3.0.10-stable.tar.gz

One of the unpacked files will be a JAR file. It doesn't matter in which directory you put that JAR file; what you need to do is include it in your classpath. When you run your program, do it like this (note: this is just an example, you'll have to fill it in correctly yourself):

java -cp /some/path/mysql-connector-java-3.0.10-stable-bin.jar:. com.mypackage.MyMainClass

Also, note that you are using GCJ (GNU Java) instead of Sun Java. GNU Java is the version of Java that comes with most Linux distributions because it is fully open source. However, it is unfortunately an incomplete and slow implementation of Java. It's much better to download and install Sun Java on your Linux system. Lookup in the documentation of your Linux distribution how to install Sun Java.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an doubt.whether i have to put the Connect1.java inside com.mypackage?i've tried like this.
java -cp /usr/share/java/mysql-connector-java-3.0.10-stable-bin.jar:. com.mypackage.Connect1
I found the following error
Exception in thread "main" java.lang.NoClassDefFoundError: com.mysql.Connect1
at gnu.gcj.runtime.FirstThread.run() (/usr/lib/libgcj.so.5.0.0)
at _Jv_ThreadRun(java.lang.Thread) (/usr/lib/libgcj.so.5.0.0)
at _Jv_RunMain(java.lang.Class, byte const, int, byte const, boolean) (/usr/lib/libgcj.so.5.0.0)
at __gcj_personality_v0 (/root/Desktop/backup/java.version=1.4.2)
at __libc_start_main (/lib/tls/libc-2.3.4.so)
at _Jv_RegisterClasses (/root/Desktop/backup/java.version=1.4.2)
inside /usr/share/java,I am having the mysql jar file and i've extracted that.there is a folder com.inside that whether i have to create a folder and put the java file?
[ December 20, 2007: Message edited by: preethi Ayyappan ]
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic