• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

configuring driver class name in init-parameter

 
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java.sql.SQLException: No suitable driver found for jdbc : oracle:thin: @localhost: 1521: orcl
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at mydbsrvtest.DBSrvtest.init(DBSrvtest.java:41)
.
.
.
.
.I am facing the above exception when I run my servlet program (in Netbeans 7.0).
I didn't configure driver class name as init parameter value as I am using ojdbc 6.jar.. Is it necssary to add driver class name..?
the following is my web.xml
my html file code is:

and servlet program code is...:


please can anyone tell me where my mistake is..?
 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to specify it somewhere. Why do you think ojdbc6.jar would be an exception?

see: JDBCConnectionFAQ
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim McGuire wrote:You need to specify it somewhere. Why do you think ojdbc6.jar would be an exception?

see: JDBCConnectionFAQ



i didn't mean ojdbc6.jar is an exception.what i mean is the driver class file is built in for oracle11g that contains ojdc6.jar with driver class file.so we need not specify it explicitely that is we need not load the class by using Class.forName("oracle.jdbc.driver.OracleDriver"); when i use type 4 jdbc driver.
so what i feel is what is the need of mentioning it in init parameters when i add jar file(that is ojdbc 6.jar) in libraries folder of my project (in IDE).If that is the case why am I facing the above error when i run my web application using glassfish 3.x server with net beans 7.0 ide.. please explain me and correct me
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swetha Bhagavathula wrote:what i mean is the driver class file is built in for oracle11g that contains ojdc6.jar with driver class file. so we need not specify it explicitely that is we need not load the class by using Class.forName("oracle.jdbc.driver.OracleDriver"); when i use type 4 jdbc driver.



The jar file may be there, but somewhere you need to tell your code to use that driver. This is proved by the exception you are getting.

 
Sheriff
Posts: 22817
132
Eclipse IDE Spring Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't like this code. You should declare your database connection as a resource, then retrieve it through JNDI. That way the container is in control of the connections, and may even use connection pooling.
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:I don't like this code. You should declare your database connection as a resource, then retrieve it through JNDI. That way the container is in control of the connections, and may even use connection pooling.


can you please describe in detail. I am not aware of how to retrieve through JNDI.. please so that I can learn...
 
Rob Spoor
Sheriff
Posts: 22817
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For Tomcat:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-resources-howto.html#JDBC_Data_Sources
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you
 
Rob Spoor
Sheriff
Posts: 22817
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
The two armies met. But instead of battle, they decided to eat some pie and contemplate this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic