• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

configuring driver class name in init-parameter

 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Java Oracle
  • Mark post as helpful
  • send pies
  • 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..?
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • 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
Java Oracle
  • Mark post as helpful
  • send pies
  • 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 Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • 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.

 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
Java Oracle
  • Mark post as helpful
  • send pies
  • 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
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
 
Swetha Bhagavathula
Ranch Hand
Posts: 112
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you
 
Rob Spoor
Sheriff
Pie
Posts: 20546
56
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic