You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Hart, Justin" <JH...@sfa.com> on 2003/12/17 00:37:30 UTC

Cannot Create Resource Instance

I get "Cannot Create Resource Instance" when attempting to open the database connection defined by the following entry in server.xml

        <Context path="" docBase="<docbase>">
          <Resource name="<name>" auth="Container" type="javax.sql.DataSource"/>
          <ResourceParams name="<name>">		
		<parameter>
			<name>factory</name><value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
		</parameter>
		<parameter><name>maxWait</name><value>5000</value></parameter> 
		<parameter><name>maxActive</name><value>4</value></parameter> 
		<parameter><name>maxIdle</name><value>5</value></parameter> 
            <parameter><name>username</name><value>JavaUser</value></parameter>
            <parameter><name>password</name><value>java</value></parameter>
            <parameter><name>driverClassName</name>
              <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value></parameter>
		<parameter><name>url</name>
			<value>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=<databasename></value>
		</parameter>
          </ResourceParams>
        </Context>

And the following in web.xml

	<resource-ref> 
		<description>DB Connection</description> 
		<res-ref-name><name></res-ref-name> 
		<res-type>javax.sql.DataSource</res-type> 
		<res-auth>Container</res-auth>
	</resource-ref> 

The java that attempts to reference this is 

            Context context = new InitialContext();
            DataSource source = (DataSource)context .lookup("java:comp/env/<name>");
            Connection con = source .getConnection();
            Statement statement = con .createStatement();

Any clue what I'm doing wrong here?

Justin 

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