Subject | firebirdsql.jar |
---|---|
Author | d_rampazo |
Post date | 2003-09-25T13:05:27Z |
Hi,
I can´t make TOMCAT (version 4.1.24) see the firebirdsql.jar. I´m
using the connection pooling, but in all cases it talks:
" org.apache.commons.dbcp.BasicDataSource@56b93a Cannot load JDBC
driver class 'null' "
What I´m doing wrong?
firebirdsql.jar is in these folders:
Tomcat/common/lib
Tomcat/server/lib
Tomcat/webapps/teste/WEB_INF/lib
How it can´t load ?
My Server.xml:
<?xml version='1.0' encoding='utf-8'?>
<Server className="org.apache.catalina.core.StandardServer" debug="0"
port="8005" shutdown="SHUTDOWN">
<Listener
className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0" jsr77Names="false"/>
<Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<GlobalNamingResources>
<Environment name="simpleValue" override="true"
type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be
updated and saved" name="UserDatabase" scope="Shareable"
type="org.apache.catalina.UserDatabase"/>
<Resource auth="Container" name="jdbc/DBFirebird"
scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
<ResourceParams name="jdbc/DBFirebird">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:firebirdsql:192.168.1.157/3050:f:\\db\\company.ib</value>
</parameter>
<parameter>
<name>password</name>
<value>masterkey</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.firebirdsql.jdbc.FBDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>SYSDBA</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<Service className="org.apache.catalina.core.StandardService"
debug="5" name="Tomcat-Standalone">
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
acceptCount="100" bufferSize="2048" compression="off"
connectionLinger="-1" connectionTimeout="20000" debug="0"
disableUploadTimeout="true" enableLookups="true"
maxKeepAliveRequests="100" maxProcessors="75" minProcessors="5"
port="8080"
protocolHandlerClassName="org.apache.coyote.http11.Http11Protocol"
proxyPort="0" redirectPort="8443" scheme="http" secure="false"
tcpNoDelay="true" useURIValidationHack="false">
<Factory
className="org.apache.catalina.net.DefaultServerSocketFactory"/>
</Connector>
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
acceptCount="10" bufferSize="2048" compression="off"
connectionLinger="-1" connectionTimeout="0" debug="0"
disableUploadTimeout="false" enableLookups="true"
maxKeepAliveRequests="100" maxProcessors="75" minProcessors="5"
port="8009"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
proxyPort="0" redirectPort="8443" scheme="http" secure="false"
tcpNoDelay="true" useURIValidationHack="false">
<Factory
className="org.apache.catalina.net.DefaultServerSocketFactory"/>
</Connector>
<Engine className="org.apache.catalina.core.StandardEngine"
debug="5" defaultHost="localhost"
mapperClass="org.apache.catalina.core.StandardEngineMapper"
name="Standalone">
<DefaultContext
className="org.apache.catalina.core.StandardDefaultContext"
cookies="true" crossContext="true" name="defaultContext"
reloadable="false" swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
</DefaultContext>
<Host className="org.apache.catalina.core.StandardHost"
appBase="/teste" autoDeploy="true"
configClass="org.apache.catalina.startup.ContextConfig"
contextClass="org.apache.catalina.core.StandardContext" debug="5"
deployXML="true"
errorReportValveClass="org.apache.catalina.valves.ErrorReportValve"
liveDeploy="true"
mapperClass="org.apache.catalina.core.StandardHostMapper"
name="localhost2" unpackWARs="true">
</Host>
<Host className="org.apache.catalina.core.StandardHost"
appBase="webapps" autoDeploy="true"
configClass="org.apache.catalina.startup.ContextConfig"
contextClass="org.apache.catalina.core.StandardContext" debug="0"
deployXML="true"
errorReportValveClass="org.apache.catalina.valves.ErrorReportValve"
liveDeploy="true"
mapperClass="org.apache.catalina.core.StandardHostMapper"
name="localhost" unpackWARs="true">
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Tomcat
Manager Application" docBase="../server/webapps/manager"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/manager" privileged="true" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<ResourceLink global="UserDatabase" name="users"
type="org.apache.catalina.UserDatabase"/>
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0"
docBase="D:/Java/TomCat/bin/../webapps/myweb"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/myweb" privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<ResourceLink global="jdbc/DBFirebird"
name="jdbc/DBFirebird" type="javax.sql.DataSource"/>
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" docBase="/teste"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="D:\Java\TomCat\webapps\teste" privileged="false"
reloadable="true" swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<Resource name="testeDB" scope="Shareable"
type="javax.sql.DataSource"/>
<ResourceParams name="testeDB">
<parameter>
<name>url</name>
<value>jdbc:firebirdsql:192.168.1.157:f:\\db\\company.ib</value>
</parameter>
<parameter>
<name>password</name>
<value>masterkey</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.firebirdsql.jdbc.FBDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>SYSDBA</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Tomcat
Examples" docBase="examples"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/examples" privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<Logger className="org.apache.catalina.logger.FileLogger"
debug="0" directory="logs" prefix="localhost_examples_log."
suffix=".txt" timestamp="true" verbosity="1"/>
<Parameter name="context.param.name" override="false"
value="context.param.value"/>
<Ejb description="Example EJB Reference"
home="com.mycompany.mypackage.AccountHome" name="ejb/Account"
remote="com.mycompany.mypackage.Account" type="Entity"/>
<Ejb home="com.wombat.empl.EmployeeRecordHome"
name="ejb/EmplRecord" remote="com.wombat.empl.EmployeeRecord"
type="Entity"/>
<Environment name="maxExemptions" override="true"
type="java.lang.Integer" value="15"/>
<Environment name="foo/name1" override="true"
type="java.lang.String" value="value1"/>
<Environment name="minExemptions" override="true"
type="java.lang.Integer" value="1"/>
<Environment name="name3" override="true"
type="java.lang.Integer" value="1"/>
<Environment name="foo/bar/name2" override="true"
type="java.lang.Boolean" value="true"/>
<Environment name="foo/name4" override="true"
type="java.lang.Integer" value="10"/>
<LocalEjb description="Example Local EJB Reference"
home="com.mycompany.mypackage.ProcessOrderHome"
local="com.mycompany.mypackage.ProcessOrder" name="ejb/ProcessOrder"
type="Session"/>
<Resource auth="Container" name="mail/Session"
scope="Shareable" type="javax.mail.Session"/>
<Resource auth="SERVLET" name="jdbc/EmployeeAppDb"
scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="mail/Session">
<parameter>
<name>mail.smtp.host</name>
<value>localhost</value>
</parameter>
</ResourceParams>
<ResourceParams name="jdbc/EmployeeAppDb">
<parameter>
<name>url</name>
<value>jdbc:HypersonicSQL:database</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.hsql.jdbcDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>sa</value>
</parameter>
</ResourceParams>
<ResourceLink global="simpleValue"
name="linkToGlobalResource" type="java.lang.Integer"/>
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Tomcat
Documentation" docBase="D:\Java\TomCat\webapps\tomcat-docs"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/tomcat-docs" privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0"
docBase="D:\Java\TomCat\webapps\teste"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/teste" privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Webdav
Content Management" docBase="D:\Java\TomCat\webapps\webdav"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/webdav" privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Welcome to
Tomcat" docBase="D:\Java\TomCat\webapps\ROOT"
mapperClass="org.apache.catalina.core.StandardContextMapper" path=""
privileged="false" reloadable="false" swallowOutput="false"
useNaming="true" wrapperClass="org.apache.catalina.core.StandardWrapper">
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Tomcat
Administration Application" docBase="../server/webapps/admin"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/admin" privileged="true" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<Logger className="org.apache.catalina.logger.FileLogger"
debug="0" directory="logs" prefix="localhost_admin_log." suffix=".txt"
timestamp="true" verbosity="1"/>
</Context>
<Logger className="org.apache.catalina.logger.FileLogger"
debug="0" directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true" verbosity="1"/>
</Host>
<Logger className="org.apache.catalina.logger.FileLogger"
debug="9" directory="logs" prefix="catalina_log." suffix=".txt"
timestamp="true" verbosity="1"/>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase" validate="true"/>
</Engine>
</Service>
</Server>
Web.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<welcome-file-list>
<welcome-file>indexx.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<resource-ref>
<res-ref-name>testeDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>DB Test</title>
</head>
<body>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<% try{ %>
try !!! <br>
<% Context ctx = new InitialContext(); %>
Context !!! <BR>
<%
if(ctx == null )
throw new Exception("Boom - No Context");
%>
CTX not null <br>
<%
DataSource ds = (DataSource)ctx.lookup("java:comp/env/testeDB");
%>
Data Source<br>
<%
if (ds != null) {
Connection conn = ds.getConnection();%>
Conected!!<br>
<% if(conn != null) { %>
Works <br>
<% } else { %>
No....<br>
<%
}
conn.close();
}
}catch(Exception e) { %>
<%=e.getMessage()%>
<% e.printStackTrace();
}
%>
</body>
</html>
[]´s
Davi Rampazo
I can´t make TOMCAT (version 4.1.24) see the firebirdsql.jar. I´m
using the connection pooling, but in all cases it talks:
" org.apache.commons.dbcp.BasicDataSource@56b93a Cannot load JDBC
driver class 'null' "
What I´m doing wrong?
firebirdsql.jar is in these folders:
Tomcat/common/lib
Tomcat/server/lib
Tomcat/webapps/teste/WEB_INF/lib
How it can´t load ?
My Server.xml:
<?xml version='1.0' encoding='utf-8'?>
<Server className="org.apache.catalina.core.StandardServer" debug="0"
port="8005" shutdown="SHUTDOWN">
<Listener
className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0" jsr77Names="false"/>
<Listener
className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<GlobalNamingResources>
<Environment name="simpleValue" override="true"
type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be
updated and saved" name="UserDatabase" scope="Shareable"
type="org.apache.catalina.UserDatabase"/>
<Resource auth="Container" name="jdbc/DBFirebird"
scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
<ResourceParams name="jdbc/DBFirebird">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:firebirdsql:192.168.1.157/3050:f:\\db\\company.ib</value>
</parameter>
<parameter>
<name>password</name>
<value>masterkey</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.firebirdsql.jdbc.FBDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>SYSDBA</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<Service className="org.apache.catalina.core.StandardService"
debug="5" name="Tomcat-Standalone">
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
acceptCount="100" bufferSize="2048" compression="off"
connectionLinger="-1" connectionTimeout="20000" debug="0"
disableUploadTimeout="true" enableLookups="true"
maxKeepAliveRequests="100" maxProcessors="75" minProcessors="5"
port="8080"
protocolHandlerClassName="org.apache.coyote.http11.Http11Protocol"
proxyPort="0" redirectPort="8443" scheme="http" secure="false"
tcpNoDelay="true" useURIValidationHack="false">
<Factory
className="org.apache.catalina.net.DefaultServerSocketFactory"/>
</Connector>
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
acceptCount="10" bufferSize="2048" compression="off"
connectionLinger="-1" connectionTimeout="0" debug="0"
disableUploadTimeout="false" enableLookups="true"
maxKeepAliveRequests="100" maxProcessors="75" minProcessors="5"
port="8009"
protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler"
proxyPort="0" redirectPort="8443" scheme="http" secure="false"
tcpNoDelay="true" useURIValidationHack="false">
<Factory
className="org.apache.catalina.net.DefaultServerSocketFactory"/>
</Connector>
<Engine className="org.apache.catalina.core.StandardEngine"
debug="5" defaultHost="localhost"
mapperClass="org.apache.catalina.core.StandardEngineMapper"
name="Standalone">
<DefaultContext
className="org.apache.catalina.core.StandardDefaultContext"
cookies="true" crossContext="true" name="defaultContext"
reloadable="false" swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
</DefaultContext>
<Host className="org.apache.catalina.core.StandardHost"
appBase="/teste" autoDeploy="true"
configClass="org.apache.catalina.startup.ContextConfig"
contextClass="org.apache.catalina.core.StandardContext" debug="5"
deployXML="true"
errorReportValveClass="org.apache.catalina.valves.ErrorReportValve"
liveDeploy="true"
mapperClass="org.apache.catalina.core.StandardHostMapper"
name="localhost2" unpackWARs="true">
</Host>
<Host className="org.apache.catalina.core.StandardHost"
appBase="webapps" autoDeploy="true"
configClass="org.apache.catalina.startup.ContextConfig"
contextClass="org.apache.catalina.core.StandardContext" debug="0"
deployXML="true"
errorReportValveClass="org.apache.catalina.valves.ErrorReportValve"
liveDeploy="true"
mapperClass="org.apache.catalina.core.StandardHostMapper"
name="localhost" unpackWARs="true">
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Tomcat
Manager Application" docBase="../server/webapps/manager"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/manager" privileged="true" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<ResourceLink global="UserDatabase" name="users"
type="org.apache.catalina.UserDatabase"/>
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0"
docBase="D:/Java/TomCat/bin/../webapps/myweb"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/myweb" privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<ResourceLink global="jdbc/DBFirebird"
name="jdbc/DBFirebird" type="javax.sql.DataSource"/>
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" docBase="/teste"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="D:\Java\TomCat\webapps\teste" privileged="false"
reloadable="true" swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<Resource name="testeDB" scope="Shareable"
type="javax.sql.DataSource"/>
<ResourceParams name="testeDB">
<parameter>
<name>url</name>
<value>jdbc:firebirdsql:192.168.1.157:f:\\db\\company.ib</value>
</parameter>
<parameter>
<name>password</name>
<value>masterkey</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>4</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>5000</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.firebirdsql.jdbc.FBDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>SYSDBA</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>2</value>
</parameter>
</ResourceParams>
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Tomcat
Examples" docBase="examples"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/examples" privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<Logger className="org.apache.catalina.logger.FileLogger"
debug="0" directory="logs" prefix="localhost_examples_log."
suffix=".txt" timestamp="true" verbosity="1"/>
<Parameter name="context.param.name" override="false"
value="context.param.value"/>
<Ejb description="Example EJB Reference"
home="com.mycompany.mypackage.AccountHome" name="ejb/Account"
remote="com.mycompany.mypackage.Account" type="Entity"/>
<Ejb home="com.wombat.empl.EmployeeRecordHome"
name="ejb/EmplRecord" remote="com.wombat.empl.EmployeeRecord"
type="Entity"/>
<Environment name="maxExemptions" override="true"
type="java.lang.Integer" value="15"/>
<Environment name="foo/name1" override="true"
type="java.lang.String" value="value1"/>
<Environment name="minExemptions" override="true"
type="java.lang.Integer" value="1"/>
<Environment name="name3" override="true"
type="java.lang.Integer" value="1"/>
<Environment name="foo/bar/name2" override="true"
type="java.lang.Boolean" value="true"/>
<Environment name="foo/name4" override="true"
type="java.lang.Integer" value="10"/>
<LocalEjb description="Example Local EJB Reference"
home="com.mycompany.mypackage.ProcessOrderHome"
local="com.mycompany.mypackage.ProcessOrder" name="ejb/ProcessOrder"
type="Session"/>
<Resource auth="Container" name="mail/Session"
scope="Shareable" type="javax.mail.Session"/>
<Resource auth="SERVLET" name="jdbc/EmployeeAppDb"
scope="Shareable" type="javax.sql.DataSource"/>
<ResourceParams name="mail/Session">
<parameter>
<name>mail.smtp.host</name>
<value>localhost</value>
</parameter>
</ResourceParams>
<ResourceParams name="jdbc/EmployeeAppDb">
<parameter>
<name>url</name>
<value>jdbc:HypersonicSQL:database</value>
</parameter>
<parameter>
<name>password</name>
<value></value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>org.hsql.jdbcDriver</value>
</parameter>
<parameter>
<name>username</name>
<value>sa</value>
</parameter>
</ResourceParams>
<ResourceLink global="simpleValue"
name="linkToGlobalResource" type="java.lang.Integer"/>
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Tomcat
Documentation" docBase="D:\Java\TomCat\webapps\tomcat-docs"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/tomcat-docs" privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0"
docBase="D:\Java\TomCat\webapps\teste"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/teste" privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Webdav
Content Management" docBase="D:\Java\TomCat\webapps\webdav"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/webdav" privileged="false" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Welcome to
Tomcat" docBase="D:\Java\TomCat\webapps\ROOT"
mapperClass="org.apache.catalina.core.StandardContextMapper" path=""
privileged="false" reloadable="false" swallowOutput="false"
useNaming="true" wrapperClass="org.apache.catalina.core.StandardWrapper">
</Context>
<Context className="org.apache.catalina.core.StandardContext"
cachingAllowed="true"
charsetMapperClass="org.apache.catalina.util.CharsetMapper"
cookies="true" crossContext="true" debug="0" displayName="Tomcat
Administration Application" docBase="../server/webapps/admin"
mapperClass="org.apache.catalina.core.StandardContextMapper"
path="/admin" privileged="true" reloadable="false"
swallowOutput="false" useNaming="true"
wrapperClass="org.apache.catalina.core.StandardWrapper">
<Logger className="org.apache.catalina.logger.FileLogger"
debug="0" directory="logs" prefix="localhost_admin_log." suffix=".txt"
timestamp="true" verbosity="1"/>
</Context>
<Logger className="org.apache.catalina.logger.FileLogger"
debug="0" directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true" verbosity="1"/>
</Host>
<Logger className="org.apache.catalina.logger.FileLogger"
debug="9" directory="logs" prefix="catalina_log." suffix=".txt"
timestamp="true" verbosity="1"/>
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
debug="0" resourceName="UserDatabase" validate="true"/>
</Engine>
</Service>
</Server>
Web.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<welcome-file-list>
<welcome-file>indexx.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/error.jsp</location>
</error-page>
<resource-ref>
<res-ref-name>testeDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</web-app>
Index.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>DB Test</title>
</head>
<body>
<%@ page import="javax.naming.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.sql.*" %>
<% try{ %>
try !!! <br>
<% Context ctx = new InitialContext(); %>
Context !!! <BR>
<%
if(ctx == null )
throw new Exception("Boom - No Context");
%>
CTX not null <br>
<%
DataSource ds = (DataSource)ctx.lookup("java:comp/env/testeDB");
%>
Data Source<br>
<%
if (ds != null) {
Connection conn = ds.getConnection();%>
Conected!!<br>
<% if(conn != null) { %>
Works <br>
<% } else { %>
No....<br>
<%
}
conn.close();
}
}catch(Exception e) { %>
<%=e.getMessage()%>
<% e.printStackTrace();
}
%>
</body>
</html>
[]´s
Davi Rampazo