How to install connector/j(mySQL-JDBC)?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 9 of 9

Thread: How to install connector/j(mySQL-JDBC)?

Hybrid View

  1. #1
    Join Date
    May 2004
    Posts
    12

    How to install connector/j(mySQL-JDBC)?

    The connector/j 3.0 available download is in binary/source files...if i wanna create a connection ...how should i set it up? thx


    p/s: im using tomcat now

  2. #2
    Join Date
    May 2004
    Posts
    5
    hi,

    there is a README inside the download, maybe you can check out the usage/installation portion.

    i have my 3.0.8 stable release on my webapp, but i really forgot how i got it working. i think... it is as simple as including the JAR file into your classpath, and using Class.forName() to load the driver.

    cheers.

    ka

  3. #3
    Join Date
    Dec 2003
    Posts
    37
    Hi KA:

    Where is "it is as simple as including the JAR file into your classpath". I was stuck on "ClassPath" on JAVA for loading SQL driver in Jtds' .JAR file.

    I got following message when I run a java application:

    ClassNotFuondException: net.sourceforge.jtds.jdbc.Driver
    SQLException: no suitable driver

    Thank you

  4. #4
    Join Date
    May 2004
    Posts
    5
    Hi,

    hmm.. well, i can't be of much help on the part of getting the JAR on your classpath unless you are using Eclipse IDE...

    But then, did you try to load the driver this way?

    Class.forName("net.sourceforge.jtds.jdbc.Driver")

    Where did you get the connector from? I assume you got them here

    I used this...

    Class.forName("com.mysql.jdbc.Driver")

    Cheers.

  5. #5
    Join Date
    Dec 2003
    Posts
    37
    Hi KA:

    I got the MS SQL Driver from Sourceforge.net. Based on they instruction I had following lines to build up Connecti on with MS SQL (MSDE) 7.0.

    String url = "jdbc:jtds:sqlserver//MSSQLPRD1:1433/DHDatabase";
    Class.forName("net.sourceforge.jtds.jdbc.Driver");

    I heve NetBeans 3.6 IDE installed but I did not use it yet. I used DOS prompt to compile and run JAVA now. I can run them with JDBC:ODBC driver on my MSDE but it was faild on third party's driver, such as JTDS from Sourceforge.net.

    One error, just l mentioned before, was to indicate "ClassPath" was not set up. Wehere it supporsted to be? How to set it up?
    I just read some articles from Sun.Java.com and they said to Set up Enviroment variables on Win NT System Properties on Control Panel for ClassPath.

    I tried it both on System/User Variables but then I got "Exception in thread "main" java.lang.NoClassDefFoundError".

    Did MySQL works on MSDE? I world like to get it a try if it does.

    Any idea to set up ClassPath?

    Thanks.

  6. #6
    Join Date
    May 2004
    Posts
    5
    Hahah.. hihi..

    We are talking about two different databases. In the thead title, you posted mySQL...

    No. mySQL driver will not work on MS SQL.

    Okay. Anyway, it should be the same procedure (hopefully)... I havent tried though.

    With regard to the classpath... i think you can try running the program this way

    e.g. your connector jar file is in c:\libs\whatever.jar

    java myDriver -classpath c:\libs

    Cheers.

  7. #7
    Join Date
    Dec 2003
    Posts
    37
    Hi Ka:

    I got the following line to work on Dos propmt with -classpath:

    C:\java -cp .;c:\j2sdk1.4.2_04\LIB/JTDS-0.8-RC1.JAR MySQLQuery

  8. #8
    Join Date
    Aug 2004
    Posts
    1

    Post

    Hello,
    I created java project and added external JAR: mysql-connector-java-3.1.3-beta-bin.jar to build path
    try {
    Class.forName("com.mysql.jdbc.Driver").newInstance();
    } catch (Exception ex) {
    System.out.println(ex.getMessage());
    }
    this code works fine
    but when i created sample eclipse plugin project, exception class not found was trown.
    what i miss??
    please help me

    P.S.
    I'm using Eclipse 3.0.0

    Thanks.

  9. #9
    Join Date
    Sep 2006
    Posts
    2
    Hey xaero,

    I had a similar problem try the following steps and it might work for you.

    1) create a new folder in your plugin project for libraries. ie: lib
    2) put the connector/j jar in this folder.
    3) in the Project->Properties->Java Build Path section, navigate to the Libraries tab and add the JAR with the Add JARs button not the Add External JARs.
    4) Go to your plugin.xml section and navigate to the Runtime tab,
    Click on your project's plugin.xml and go the runtime tab, add the jar in the Classpath section. Make sure to refresh your project before you do this or you might not see the JAR file when you moved it to your lib folder.
    5) In the build tab of your plugin.xml section, make sure you lib folder has a checkmark beside it.

    Apparently you can't have a JAR added externally and have it work properly when your plugin is used.

    Hopefully it should work now!

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