Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Database connectiivity Error using DataSource  RSS feed

 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a databse connectivity in jsp page & it givs me an exception:

javax.naming.NamingException: Cannot create resource instance
in server.xml my entry is.
//--------------------------------------------------------------------

<Resource name="jdbc/myoracle" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/myoracle">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc racle:thin:@80.0.0.12:1526 RACLE</value>
</parameter>
<parameter>
<name>username</name>
<value>sol</value>
</parameter>
<parameter>
<name>sol</name>
<value>tiger</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>
//--------------------------------------------------------------------
web.xml

<resource-ref>
<description>DATA SOURCE FOR TRACK JOB SHEETS</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.Datasource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
//----------------------------------------------------------------------
// CODE FOR GETTING CONNECTION
InitialContext initCtx=new InitialContext();
Context ctx=(Context) initCtx.lookup("java:/comp/env");
DataSource ds=(DataSource)ctx.lookup("jdbc/myoracle");
//-------------------------------------------------------------------

thanks
 
James Carman
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have the oracle driver jar in <TOMCAT_HOME>/common/lib?

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/jndi-datasource-examples-howto.html
 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi James Carman
I went through with given URL... I am doing every thing right..
oracle driver is at right place under $TOMACAT_HOME$/COMMON/LIB/

GENRATED THIS EXCEPTION>>>>

org.apache.jasper.JasperException: Cannot create JDBC driver of class '' for connect URL 'null', cause: null

thanks
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vijay Kumar:



Is it a typo? I think it should be like

 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Adil I have typed correctd..
bt now My code is givin error

Cannot create JDBC driver of class '' for connect URL 'null', cause: null


although in server.xml & web.xml contains the correct entries
in server.xml I have supplied the driverClassName ,url.

Thanks
 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
thank..
my has been resolved....

vijay
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Vijay Kumar:
hi all
thank..
my has been resolved....

vijay


what was the real cause mate?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!