• Post Reply Bookmark Topic Watch Topic
  • New Topic

JNDI javax.naming.NamingException  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");
//-------------------------------------------------------------------


THANKX
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!