aspose file tools*
The moose likes JDBC and the fly likes Need help in Connecting my MySQL Database to JTable in Eclipse. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Need help in Connecting my MySQL Database to JTable in Eclipse." Watch "Need help in Connecting my MySQL Database to JTable in Eclipse." New topic
Author

Need help in Connecting my MySQL Database to JTable in Eclipse.

Bobby Johnson
Greenhorn

Joined: Jan 05, 2009
Posts: 3
Good morning everyone. I am having trouble connecting my MySQL database to a JTable in Eclipse. I keep on getting an exception and receiving this message "Unable to find and load database driver". Here is a sample of database code for the program:



I omitted the username and password in this sample code for security purposes. I have also included the MySQL driver .jar file into the WEB/Inf folder and I still cannot connect the database into the JTable. Could anyone give me any suggestions to resolve this issue? I am using Eclipse 3.3 Java EE platform.
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1


Just put the MySQL Driver .jar file into a CLASSPATH variable.


[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38910
    
  23
Welcome to JavaRanch

Sagar Rohankar is correct, but I would like to give a bit more detail.
  • R-click the name of your project.
  • Properties
  • Java Build Path
  • Add External .jars
  • Browse, and find the .jar
  • OK OK OK OK
  • . . . or something similar to that lot; I am writing from memory.
    Bauke Scholtz
    Ranch Hand

    Joined: Oct 08, 2006
    Posts: 2458
    Bobby Johnson wrote:I have also included the MySQL driver .jar file into the WEB/Inf folder

    WEB/Inf? Sigh.

    Please read this: http://faq.javaranch.com/java/ShowSomeEffort

    and I still cannot connect the database into the JTable.

    First this: is it a web app (because you vaguely said something about WEB/Inf) or a desktop app (that´s where JTable is for) or an applet or JNLP application embedded in a page of the web app? This is important to know, because the default classpath locations differs in each of those environments.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Need help in Connecting my MySQL Database to JTable in Eclipse.