In the server.xml, nested in the <GlobalNamingResources> tags, I have:
<Resource name="SQLServer2000" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="SQLServer2000"> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> <parameter> <name>username</name> <value>#USERNAME#</value> </parameter> <parameter> <name>password</name> <value>#PASSWORD#</value> </parameter> <parameter> <name>driverClassName</name> <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value> </parameter> <parameter> <name>url</name> <value>jdbc:microsoft:sqlserver://#HOST#:#PORT#;databasename=#DB#</value> </parameter> <parameter> <name>removeAbandoned</name> <value>true</value> </parameter> <!-- Seconds before a connection is considered abandoned --> <parameter> <name>removeAbandonedTimeout</name> <value>100</value> </parameter> <!-- Maximum number of dB connections in pool. 0 for no limit --> <parameter> <name>maxActive</name> <value>100</value> </parameter> <!-- Maximum number of idle dB connections to retain in pool. 0 for no limit --> <parameter> <name>maxIdle</name> <value>5</value> </parameter> <!-- Maximum time to wait for a dB connection to become available, in microseconds. -1 is indefinitely. --> <parameter> <name>maxWait</name> <value>-1</value> </parameter> <parameter> <name>validationQuery</name> <value>SELECT 1</value> </parameter> </ResourceParams> Then, in the web application's context.xml (or its <Context> entry in the server.xml if you're deploying it that way) I create a link to the global resource: <Context ...> ... <ResourceLink name="jdbc/SQLServ" global="SQLServer2000" type="javax.sql.DataSource" /> </Context> Finally, in the code: public class DatabaseConnection { private static DataSource dataSource; public static Connection getConnection() throws SQLException, ClassNotFoundException { if (dataSource == null) { try { Context init = new InitialContext(); Context ctx = (Context) init.lookup("java:comp/env"); dataSource = (DataSource) ctx.lookup("jdbc/SQLServ"); } catch (NamingException E) { throw new SQLException(E.toString()); } } synchronized (dataSource) { return dataSource.getConnection(); } } } I have the database connections as a "global resource" so multiple web applications can use the same pool of connections (just have to link each web app via the Context). I can elaborate -- just let me know where you want it. Gotta get out of the office for now :) Jim -----Original Message----- From: Frank Schaare [mailto:[EMAIL PROTECTED] Sent: Monday, March 01, 2004 5:22 PM To: [EMAIL PROTECTED] Subject: MS SQL Server 2000 as JNDI Datasource Hi, i´m looking for a working configuration (like in the JNDI Datasource HOW-TO) for MS Sql Server 2000. We´re using the MS JDBC driver. I´ve searched the mail-archives for hours now, found tons of threads, but no answer. Any suggestions / help / sources for me ? --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]