Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Oracle JDBC driver and JSP

 
Winston Smith
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've created a bean which connects to a database. The following import statement is included in the bean class file:
import oracle.jdbc.driver.OracleDriver;
The bean works fine as a stand-alone program, however, when I try to create the bean in a JSP page, Tomcat returns a ClassNotFound Exception for driver.OracleDriver. If the driver is already imported in the .class file, why can't it be seen in the JSP page? I'm thinking I may need to place the driver file (class12.jar) somewhere in the Tomcat directory. Also, I'm running everything on the same machine, so JSP should have access to the driver.
Any suggestions?
Thanks,
WS
 
Manish Sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

You just put the class12.jar file into the web-inf\lib directory and also all required jar files.
related to your applications for example if you are using mail service so put the mail.jar and activation.jar into that.
hope it will help you.
waiting for reply.
with regards
Manish
Originally posted by Winston Smith:
I've created a bean which connects to a database. The following import statement is included in the bean class file:
import oracle.jdbc.driver.OracleDriver;
The bean works fine as a stand-alone program, however, when I try to create the bean in a JSP page, Tomcat returns a ClassNotFound Exception for driver.OracleDriver. If the driver is already imported in the .class file, why can't it be seen in the JSP page? I'm thinking I may need to place the driver file (class12.jar) somewhere in the Tomcat directory. Also, I'm running everything on the same machine, so JSP should have access to the driver.
Any suggestions?
Thanks,
WS
 
Winston Smith
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Manish! I don't have a web-inf/lib directory, so I ended up putting it in the bin directory and it's working from there! Hahhaa, I was dreading coming to work this morning because I was going to do battle with this Oracle driver, but you've saved me from the torture!
Thanks again,
WS
 
Manish Sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thats very good your code is running now but my advice is to you that you should make a web-inf directory into your webapplication directory and put web.xml,related jar files. if you need to transfer your web-application to another machine or webserver directly put that directory in it. no need put again all jar into webserver's bin directory. it will be complete application directory.
waiting for reply.
with regards
Manish Sharma

Originally posted by Winston Smith:
Thanks, Manish! I don't have a web-inf/lib directory, so I ended up putting it in the bin directory and it's working from there! Hahhaa, I was dreading coming to work this morning because I was going to do battle with this Oracle driver, but you've saved me from the torture!
Thanks again,
WS
 
bharat nagpal
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally When webserver starts it picks all the jar files from WebServer\lib directory and put them in classpath for all the applications running in the webserver. and If you want some file in the classpath for a particular application you can put the file in the directory mentioned by manish.and the third way is to put the file in the classpath of the system(machine).
just by putting in bin directory i don't think it would be in classpath!!! how cum !!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic