Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: No suitable driver

 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All ,

I am new to jsp , trying to work with data source (mysql ) using tomcat 6 , I have read the tutorial from the link


but am getting the following error :





I have placed mysql connector jar in tomcat lib as well as in my example project web-info/lib , but still getting the same error

context.xml





web.xml




test.jsp





by the way i have another jsp page in the same example project which access the database but without data source and it worked fine

Any suggestion .
 
Scott Selikoff
author
Saloon Keeper
Posts: 4020
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never connect to a database inside a JSP!!!

That said, have you tried checking the JDBC FAQ? It doesn't look like your register the driver, ie Class.forName().
 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Scott Selikoff for your reply ,

As per your reply I have make the data connection in a separate bean & i have registered the driver as the following





, but am getting the same error ..



any suggestion
 
Ram Narayan.M
Ranch Hand
Posts: 247
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have mysql-connector jar file in tomcat lib since all other web applications will use it...

And make sure that the CLASSPATH has been set for mysql-connector jar in tomcat lib...
 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ram thanks alot for your reply,

I have followed your steps in your reply but still facing the same issue.
 
Malatesh Karabisti
Ranch Hand
Posts: 153
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two ways to get the Connection Object

1)DataSource
2)DriverManager

seems like you are trying both if you are just doing some test application use DriverManager find out the difference between DataSource and DriverManager
 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Malatesh Karabisti for your reply ,

There are two ways to get the Connection Object

1)DataSource
2)DriverManager

seems like you are trying both if you are just doing some test application use DriverManager find out the difference between DataSource and DriverManager





I have already did some small test applications using DriverManager and it worked fine now I want to use DataSource but am still getting this error ........
 
Suresh Khant
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any suggestion............
 
Rich Burke
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm facing the same issue trying to use a DataSource with tomcat6 and mysql. Did you ever figure out the issue?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic