0

I have a problem when I try to make database calls from a web application.

I'm using a javabean to make these calls. I have already tested this bean, and it is working in classical application (i mean: not a web application).

I tried to use it in a jsp pages, but it didn't work. I got an exception:

>java.sql.SQLException
No suitable driver found for jdbc:mysql://localhost:3306/db_hafic?relaxAutoCommit=true 

I read articles about how to make database calls from within tomcat environment, but I'm still quite lost.

I'm using jsp/tomcat/mysql.

Sergey Benner
  • 4,421
  • 2
  • 22
  • 29

2 Answers2

3

First read the documentation:

Install the .jar file(s) containing the JDBC driver in Tomcat's common/lib folder. You do not need to put them in your application's WEB-INF/lib folder. When working with J2EE DataSources, the web application server manages connections for your application.

kgiannakakis
  • 103,016
  • 27
  • 158
  • 194
0

3 common problems:

  1. Incorrect syntax Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/XX","root","XXXX")

  2. Typo mistake on "com.mysql.jdbc.Driver" e.g. Class.forName("com.mysql.jdbc.Driver").newInstance();

  3. Missing mysql_jdbc Jar Include the latest mysql jdbc driver in your tomecat classpath

your situation should be the problem 3, download the driver at http://www.mysql.com/downloads/connector/j/

add the library at WEB-INF/lib/ and deploy again.

Hope it can help!

Aliaksei Kliuchnikau
  • 13,589
  • 4
  • 59
  • 72
Calvin Lai
  • 83
  • 1
  • 7