Wednesday 15 February 2012

java - Connecting to a MqSql DataBase with jdbc -



java - Connecting to a MqSql DataBase with jdbc -

i have simple code needs connect mysql db , execute query.

try { conn = drivermanager.getconnection("jdbc:mysql://localhost/test?user=root&password=1234"); statement stm = conn.createstatement(); stm.executequery(query); homecoming true;

this code works charm in test project class void main. in project web application, i'm using apache tomcat , same code displays error:

sqlexception: no suitable driver found jdbc:mysql://localhost/test?user=root&password=1234

i've added jar, classpath everything. there special need because i'm using tomcat? thanks, dragos

use:

class.forname("com.mysql.jdbc.driver"); conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/test?user=root&password=1234");

java mysql tomcat jdbc

No comments:

Post a Comment