• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

java.sql.SQLException: No suitable driver found

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I am new to sql. I am using SQL server 5.5 db.

I would like to establish JDBC connection for a helloworld web application.

I have downloaded jar(mysql-connector-java-5.1.22-bin.jar) for jdbc connection.

When I excecute the code,exception is thrown "java.sql.SQLException: No suitable driver found"

java.sql.SQLException: No suitable driver found for jdbc://localhost:3306/shop
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at com.user.auth.HelloWorldServlet.doGet(HelloWorldServlet.java:23)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:403)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:301)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:162)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:140)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:309)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Please suggest me a valid solution.

Regards,
Anand
 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can you post us the connection code as well please.
It looks like your connection URL may be a problem, but that is just a guess.
 
Sheriff
Posts: 26776
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Anand Sivathanu wrote:I am new to sql. I am using SQL server 5.5 db.



This is Microsoft's SQL Server? Or did you just use "SQL server" as a general description and you're actually using some other database? (If so, which one?)

I have downloaded jar(mysql-connector-java-5.1.22-bin.jar) for jdbc connection.



That suggests you're using MySQL as your database. That JDBC driver will only work with MySQL, so if you are using some other database, you should start by getting the JDBC driver which goes with it.
 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


This is the connection code....

Class.forName("com.mysql.jdbc.Driver");


Connection con = DriverManager.getConnection("jdbc://localhost:3306/shop","root","root");


Database is MySQL server 5.0. previously i tried in MySQL Server 5.5

Getting same error for both the versions
 
Ranch Hand
Posts: 296
Eclipse IDE Firefox Browser Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In what folder did you placed the "mysql-connector-java-5.1.22-bin.jar" ?
 
Wendy L Gibbons
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just done a quick search for mysql connection urls and all the examples followed this pattern:


they include jdbc:mysql

infact this looks goos oracle docs
 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wendy Gibbons,

As you said,
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shop","root","root");(right)

will work..I will try this in my machine and let you know



Connection con = DriverManager.getConnection("jdbc://localhost:3306/shop","root","root"); (wrong)

Sumit Patil,

"mysql-connector-java-5.1.22-bin.jar" placed in WEB-INF\lib.
 
Anand Sivathanu
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends,

Now I can able to access the table.

Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/shop","root","root");(right code)

Previously it was

Connection con = DriverManager.getConnection("jdbc://localhost:3306/shop","root","root");(wrong code).missing "mysql" near jdbc caused the problem(As Wendy Gibbons said)

Regards,
Anand

 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic