• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Bobby Johnson
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Just put the MySQL Driver .jar file into a CLASSPATH variable.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49813
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
    Posts: 2458
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    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.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic