Page 1 of 1

No suitable driver, JDBC on a servlet

PostPosted: 11. December 2009 23:52
by The zxeno prophet
Edit: I solved my problem, the url was badly wirtten, apparently if the url is badly writted sometime the DriverManager give you a "'No suitable driver"

So I guess it's pretty clear from the title, I'm trying to make a servlet that will connect to a local database, everything is under XAMPP (Tomcat, Apache and MySql I mean). But when I try to connect with :
Code: Select all
m_Connection = DriverManager.getConnection("jdbc:mysql:" + url + "test?user="+ login +"&password=" + password);


I get a SQLException : No suitable driver

So of course I loaded the driver before, I tried :
-com.mysql.jdbc.Driver
-org.gjt.mm.mysql.Driver

I tried with the newInstance() method and with both driver at the same time (I know it sound stupid but who knows =P)
Does anybody know what is appening ?

Edit: forgot to mention the XAMPP version it's 1.7.2 (the last stable version if I'm correct)

Re: No suitable driver, JDBC on a servlet

PostPosted: 12. December 2009 00:00
by Izzy
Did you install the Tomcat addon?

IF so, is Tomcat showing running in your XAMPP Control Panel?

Re: No suitable driver, JDBC on a servlet

PostPosted: 12. December 2009 00:19
by Wiedmann
So of course I loaded the driver before, I tried :

You have installed one of those drivers?

Re: No suitable driver, JDBC on a servlet

PostPosted: 12. December 2009 13:45
by The zxeno prophet
Izzy wrote:Did you install the Tomcat addon?

IF so, is Tomcat showing running in your XAMPP Control Panel?

Yeah of course, the servlet is running fine
edit: except for that exception of course

Wiedmann wrote:
So of course I loaded the driver before, I tried :

You have installed one of those drivers?

By installed you mean coping the library into WEB-INF/lib folder of the servlet right ? Also I'm devloping the servlet with eclipse do I have to do something more to install the drivers ?

btw the driver lib I'm using is the J-Connector 5.1.10 download from mysql website

Re: No suitable driver, JDBC on a servlet

PostPosted: 12. December 2009 14:05
by Wiedmann
By installed you mean coping the library into WEB-INF/lib folder of the servlet right ?

If I read this correctly:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#MySQL%20DBCP%20Example
You must copy the jar to "\xampp\tomcat\lib".

Re: No suitable driver, JDBC on a servlet

PostPosted: 12. December 2009 14:23
by The zxeno prophet
Wiedmann wrote:
By installed you mean coping the library into WEB-INF/lib folder of the servlet right ?

If I read this correctly:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html#MySQL%20DBCP%20Example
You must copy the jar to "\xampp\tomcat\lib".

Apparently it works with both folder, I guess it depends if you want your servlet to use a special version of the J-Connector or not

Also I solved my problem, the url was badly writted and apparently it give the "No suitable driver"