Forums Register Login

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

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send

Just put the MySQL Driver .jar file into a CLASSPATH variable.
+Pie Number of slices to send: Send
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.
    +Pie Number of slices to send: Send
     

    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.
    It wasn't my idea to go to some crazy nightclub in the middle of nowhere. I just wanted to stay home and cuddle with this tiny ad:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 2958 times.
    Similar Threads
    Getting Last Record in Jtable
    J Table Update (it makes me mad)
    gsl.sql.driv
    SQLServerException - could not connect to the host on port 1433
    Help: Connecting MySQL Database to JTable
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 29, 2024 00:31:08.