tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Roberto Pellegrino <roberto.pellegr...@quix.it>
Subject Tomcat data source
Date Tue, 04 Dec 2007 10:00:45 GMT
Hi all,
i use Tomcat *5.5.17 *my question is quite simple: it's possible to use 
a dataSource that are not defined on webApp context???

I define the dataSource on server.xml as follow:

<Resource auth="Container" driverClassName="DriverClassName"
        validationQuery="select count(*) from table"
        maxActive="100" maxIdle="30" maxWait="10000" 
name="jdbc/DataSourceName"
        password="pass" type="javax.sql.DataSource" 
url="jdbc:DBMS://ServerName:Port/dbName" username="user"/>
   
After, i want to be able use this dataSource on java program...
Normally this is the java code to get the dataSource:
    InitialContext initialContext = new InitialContext();
    DataSource ds = (DataSource) 
initialContext.lookup("jdbc:DBMS://ServerName:Port/DbName");
    conn = ds.getConnection();
If the dataSource is not defined on context (<ResourceLink 
name="jdbc/DataSourceName" global="jdbc/DataSourceName" 
type="javax.sql.DataSource"/>) the code return an exception:

Name DataSourceName is not bound in this Context.

Any Suggestions????

Robert.

















---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message