Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Tomcat Users »

can't get (Sybase ASE 12.5) database connection, maybe prob with tomcat
config?

Alan Czajkowski

2003-12-12


i'm having some trouble setting up a datasource on apache/tomcat that
comes bundled with sun's solaris 9

i copied the jConnect5.5 jconn2.jar file to /usr/apache/tomcat/common/lib

i pasted the new context (for connecting to the database) into the server.xml file in /var/apache/tomcat/conf

the directory tree for the webapps looks like so:
/var/apache/tomcat/webapps/sybase/jsp/sybase.jsp
/var/apache/tomcat/webapps/sybase/WEB-INF/web.xml
/var/apache/tomcat/webapps/sybase/WEB-INF/jsp/

i then stopped and then re-started apache

when i call /var/apache/tomcat/webapps/sybase/jsp/sybase.jsp (it's a connection test file that Sybase provides) through http://hostname:port/sybase/jsp/sybase.jsp
i get this error:
Start of Test
initCtx = new InitialContext() : successful
javax.naming.InitialContext@(protected)
envCtx = initCtx.lookup(java:comp/env) : successful
org.apache.naming.NamingContext@(protected)
Trying ds=(DataSource)envCtx.lookup(jdbc/a_sybase_datasource)
Datasource lookup failed
javax.naming.NamingException: Cannot create resource instance
DataSource null
Inside catch(Exception e)
null java.lang.NullPointerException
End of Test

any ideas?

context in server.xml
------------------------------
<!-- Sybase Example Context - dscp example -->

<Context path="/sybase"
docBase="sybase"
debug="5"
reloadable="true"
crossContext="true">

<Logger className="org.apache.catalina.logger.FileLogger"
prefix="localhost_Sybase.log."
suffix=".txt"
timestamp="true"/>

<Resource name="jdbc/a_sybase_datasource"
auth="Container"
type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/a_sybase_datasource">

<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>

<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>

<parameter>
<name>maxIdle</name>
<value>5</value>
</parameter>

<parameter>
<name>maxWait</name>
<value>10000</value>
</parameter>

<parameter>
<name>driverClassName</name>
<value>com.sybase.jdbc2.jdbc.SybDriver</value>
</parameter>

<parameter>
<name>url</name>
<value>jdbc:sybase:Tds:10.34.34.34:4300/mydb?JCONNECT_VERSION=6</value>
</parameter>

<parameter>
<name>username</name>
<value>myuser</value>
</parameter>

<parameter>
<name>password</name>
<value>mypasswd</value>
</parameter>

</ResourceParams>
</Context>

<!-- END Sybase Example Context - dscp example -->
-------------------------------------


Thanks,

Alan Czajkowski
-------------------------------------
Database Administrator
BMO Financial Group
Decision Support Services
3300 Bloor Street West
14th Floor, West Tower
Toronto, Ontario, M8X 2X2
Tel: 416.232.8736
-------------------------------------
©2008 junlu.com - Jax Systems, LLC, U.S.A.