jdbc and mysql


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: jdbc and mysql

  1. #1
    Join Date
    May 2004
    Posts
    2

    jdbc and mysql

    I am currently using jdbc to connect to a mysql database with the mysql driver mysql-connector-java-3.0.11-stable.jar (com.mysql.jdbc.Driver). It works just fine in JBuilder once it was added to JBuilders internal classpath. But no matter what I do I can't manage to get it to run from a jar file after setting windows xp pro classpath. Here is my classpath.
    CLASSPATH=%CLASSPATH%;.;c:\mysql\jdbc\mysql-connector-java-3.0.11-stable-bin.jar

    The correct path for the file is:
    C:\mysql\jdbc\mysql-connector-java-3.0.11-stable.jar

    I have also tried unzipping the jar file and then changing the class file to match the correct path but anyway I go I still get an exception.

    I have rebooted since I changed the path. I have also tried manually setting the classpath when I exec the jar file with

    java -cp C:\mysql\jdbc\mysql-connector-java-3.0.11-stable.jar -jar Res.jar

    Any help is great, Its about to drive me crazy. Thanks

  2. #2
    Join Date
    Feb 2004
    Posts
    808
    your classpath is incorrect.

    you cannot edit the environment variable in that way and have your classpath come correct..

    edit the classpath (right click my computer.. properties.. advanced.. env vars.. system vars.. classpath.. edit) to be:

    c:\j2sdk_1.4.2_03\jre\lib\rt.jar;c:\mysql\jdbc\mysql-connector-java-3.0.11-stable-bin.jar;.

    then DO NOT PUT the -cp switch into java..
    just

    java -jar Res.jar

    no need to reboot, but you MUST close all command prompt windows and open a new one after you edit the variable
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  3. #3
    Join Date
    Feb 2004
    Posts
    808
    note that your java2 sdk might not be installed at that location.. edit the path, or better, edit the path in the JAVA_HOME dir, then make your classpath to be:

    %JAVA_HOME%\jre\lib\rt.jar...(and so on)
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center