• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

having trouble getting eclipse Dynamic Web Project to access mysql database

 
Joe McTigue
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Joe McTigue
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic