You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "MARU, SOHIL (SBCSI)" <sm...@sbc.com> on 2004/04/09 18:13:10 UTC

Commons DBCP

Hello All,
    I have been scouring the mailing list archives and lot of other
places. I am seeing a problem configuring a datasource with Tomcat. I
have tried putting it in global and that too fails. Please note, the
error is that it is unable to create instance of
oracle.jdbc.driver.OracleDriver not that it can't find it. I changed the
driverClassName to something weird and then it said Cannot find class,
but right now its not able to create an Instance of the oracle driver
for some reason. 
I have put the following entry in my server.xml

				<Context path="/loa"
docBase="C:\software\eclipse\workspace\HRTechnology\TOMCAT_ROOT"
reloadable="true">
					<Resource name="jdbc/loacenet"
auth="Container" type="javax.sql.DataSource"/>
					<ResourceParams
name="jdbc/loacenet">
						<parameter>
					       	<name>factory</name>
	
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
					       </parameter>
		        			<parameter>
	
<name>username</name>
	
<value>cent</value>
		        			</parameter>
					       <parameter>
					       	<name>password</name>
	
<value>*******</value>
					       </parameter>
					       <parameter>
	
<name>driverClassName</name>
	
<value>oracle.jdbc.driver.OracleDriver</value>
		        			</parameter>
					       <parameter>
		       				<name>url</name>
	
<value>jdbc:oracle:thin@databasemachinename:1521:sid</value>
					       </parameter>
		        			<parameter>
	
<name>maxActive</name>
	
<value>10</value>
		        			</parameter>
		        			<parameter>
	
<name>maxIdle</name>
	
<value>100</value>
		        			</parameter>
		        			<parameter>
	
<name>maxWait</name>
	
<value>3000</value>
		        			</parameter>
					</ResourceParams>
				</Context>
However when I try to load my plugin in the struts application, I get
the following exception. I looked at everything on archives and on there
people were complaining about NULL for driverClassName, in my case, it
reads the drivername and url properly and still blows up. Please help. I
am using Tomcat 5.0 with the latest
ojdbc14.jar/commons-dbcp-1.1.jar,commons-pool-1.1.jar in common/lib and
am trying to connect to oracle 8.1.7. 

org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of
class '
oracle.jdbc.driver.OracleDriver' for connect URL
'jdbc:oracle:thin@[machinename]
:1521:[sid]', cause:
java.sql.SQLException: No suitable driver
        at java.sql.DriverManager.getDriver(DriverManager.java:243)
        at
org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSou
rce.java:743)
        at
org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource
.java:518)
        at
com.sbc.hrtech.framework.utility.InitializerPlugin.init(InitializerPl
ugin.java:41)
        at
org.apache.struts.action.ActionServlet.initModulePlugIns(ActionServle
t.java:1158)
        at
org.apache.struts.action.ActionServlet.init(ActionServlet.java:473)
        at javax.servlet.GenericServlet.init(GenericServlet.java:256)
        at
org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.
java:1044)
        at
org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:88
7)
        at
org.apache.catalina.core.StandardContext.loadOnStartup(StandardContex
t.java:3960)
        at
org.apache.catalina.core.StandardContext.start(StandardContext.java:4
283)
        at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)

        at
org.apache.catalina.core.StandardHost.start(StandardHost.java:832)
        at
org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)

        at
org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518
)
        at
org.apache.catalina.core.StandardService.start(StandardService.java:5
19)
        at
org.apache.catalina.core.StandardServer.start(StandardServer.java:234
5)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:598)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:297)
        at
org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:398)
Excpetion in InitializerPlugin


The java code in the plugin is as follows
			Context init = new InitialContext();
			Context ctx = (Context)
init.lookup("java:comp/env");
			DataSource dataSource = (DataSource)
ctx.lookup("jdbc/loacenet");
			c = dataSource.getConnection(); -- line which
blows up
			st = c.createStatement();




---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org