File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes having trouble getting eclipse Dynamic Web Project to access mysql database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "having trouble getting eclipse Dynamic Web Project to access mysql database" Watch "having trouble getting eclipse Dynamic Web Project to access mysql database" New topic
Author

having trouble getting eclipse Dynamic Web Project to access mysql database

Joe McTigue
Ranch Hand

Joined: Mar 05, 2012
Posts: 52
Hi All,

I've setup my project using Eclipse juno, Mysql, and a tomcat 7 server.
The server is working great changing between pages and such, but when ever I try to access my database I get the following error:
"SQLException: getUserID -> No suitable driver found for jdbc:mysql://localhost/certstudy"

I setup the 'Data Source Explorer' and tested it with a "success!".
But, I've never connected to a database before using eclipse.
Question: After setting up the Data Source Explorer, I created a class that creates the database connection and has methods which call my stored procedures to retreive data requests.
this class is being called by my validation servlet.
Is this the correct way to access data from a 'Dynamic Web Project' in eclipse?
If not, could someone explain step by step, or point me towards a resource online for this?

Also, I am kinda worries about screwing up user sessions, which I think java should handle behind the seens I heard.
any comment on this as well is welcome.

Thanks, I really appreciate any help in advance.
-Joe
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

When working with a web app, you have to ensure that the JDBC driver is included either in your WAR file or in the lib directory of the app server (Tomcat in your case). So, registering the MySQL JDBC driver with Eclipse is not enough. You need to also include the JDBC driver in the Build Path for your web application project. (This is yet another example of where an IDE, in its effort to be helpful, has instead caused confusion and problems.)


JBoss In Action
Joe McTigue
Ranch Hand

Joined: Mar 05, 2012
Posts: 52
Hi Peter,

Thanks very much for your reply.
I figured this out and corrected the issue I was having by droping a copy of the driver jar file into the C:\Users\Joseph\workspace\certificationace\certificationace\WebContent\WEB-INF\lib folder manually.
then I returned to the Eclipse IDE and right clicked on the same lib folder in the 'Project Explorer' tree
and selected 'refresh'. Then the jar file apeared and all further tests were successfull. :-)
I also removed my previous jar file I had placed via the Eclipse IDE under the project/Java Resources/libraries path.

Thanks for your comments.
next, I will be atempting to change queryString requests to calls to my stored procedures. ;-)

Let me know if you have any suggestions for performance issues I might consider.

Have a great day!
-Joe
 
GeeCON Prague 2014
 
subject: having trouble getting eclipse Dynamic Web Project to access mysql database