Meaningless Drivel is fun!
The moose likes JDBC and Relational Databases and the fly likes Problem in connecting MySql with Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Problem in connecting MySql with Servlets" Watch "Problem in connecting MySql with Servlets" New topic
Author

Problem in connecting MySql with Servlets

Thamu Gurung
Ranch Hand

Joined: Feb 02, 2010
Posts: 39
Hi,

Thankyou for helping me in Swing and IO. Now i got strucked in Servlets , i did proper matching and all , but could not establish the connetion between MYSql and Servlets. I visited to other threads but could not get the solution.

- The version of Mysql installed is 5.1.43-comunity
- The driver which i have used is mysql-connector-java-5.1.12

The codes which i am using is



The errror msg displayed is as follows :-
exception

javax.servlet.ServletException: Servlet Could not display records.
DBConnection.service(DBConnection.java:42)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

java.sql.SQLException: No suitable driver found for jdbc:mysql://192.168.10.59:3306/thamu
java.sql.DriverManager.getConnection(Unknown Source)
java.sql.DriverManager.getConnection(Unknown Source)
DBConnection.service(DBConnection.java:29)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

Hoping to have help ,as new in Java.

Regards ,
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

put the driver jar into the application/server classpath. if you sue tomcat then typically at tomcat/lib(in tomcat6.X) and tomcat/common/lib(in tomcat5.X)
Thamu Gurung
Ranch Hand

Joined: Feb 02, 2010
Posts: 39
Dear Mr. Seetharaman,

I did but its still not working , I just copied the source code from net and tried to get the connection. The code which i am using is follows:-



and thes servlet mapping is done like in this in the XML file ...



I copied the jar file in the tomcat6/lib , but still getting the same error when trying to get the page http://localhost:8080/tryconnect/DBConnection.do

please suggest if you could please help me out with this . Will be thankful to you.

Regards ,

Rajkumar balakrishnan
Ranch Hand

Joined: May 29, 2008
Posts: 445

Try to copy the required jar into your project lib folder. The problem's cause might be of unmatched driver. Please check that too.


Never try to be a hard-worker. Be a smart-worker.
My Blog
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

"jdbc:mysql://192.168.10.59:3306/thamu"


probably your url is wrong for the appropriate sql-coonnector jar
Thamu Gurung
Ranch Hand

Joined: Feb 02, 2010
Posts: 39
hi ,

Thankyou for your replies ,, i figured it out and now its working ....

I have to copy that jar file in to jdk/jre , which i did not . but its done now and working well.

Thanks.

I have posted new thread please help me in that .

Regards
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in connecting MySql with Servlets
 
It's not a secret anymore!