Win a copy of Head First Android this week in the Android forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2908
1
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Just put the MySQL Driver .jar file into a CLASSPATH variable.
 
Marshal
Posts: 74359
334
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Ranch Hand
    Posts: 2458
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • 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.
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    reply
      Bookmark Topic Watch Topic
    • New Topic