users@glassfish.java.net

JDBC Configuration Via Context.xml

From: <glassfish_at_javadesktop.org>
Date: Fri, 14 Sep 2007 14:58:30 PDT

I'm trying to move an application from Tomcat to Glassfish and one task involved in this is configuring a JDBC datasource.
I've tried using the built-in methods for configuring a JDBC datasource (asadmin) and this works just fine.
However, the method that suites the project's needs the best (and the one employed in the Tomcat-based build) is configuration via a context.xml file. I've seen Amy Roh's Blog on this subject (http://weblogs.java.net/blog/amyroh/) and looked through some relevant threads (http://forums.java.net/jive/thread.jspa?messageID=218560) on these message boards but can't seem to find the information I need to get this working.

I started with the context.xml file from the Tomcat build. I've tried putting this file in both the 'glassfish/domains/domain1/config/' directory and in the '/META-INF/' directory in my application.
I've also tried modifying the file in various ways. The two different styles of resource entry I've tried are the following:

        <Resource
                name="jdbc/MSDBOne"
                auth="Container"
                type="javax.sql.DataSource"
                driverClassName="com.microsoft.jdbcx.sqlserver.SQLServerDataSource"
                url="jdbc:microsoft:sqlserver://192.168.1.71;user=web;password=pass;databasename=DBOne"/>

and


        <Resource
                name="jdbc/MSDBOne"
                auth="Container"
                type="javax.sql.DataSource"/>
                   
        <ResourceParams name="jdbc/MSDBOne" >
                <parameter>
                        <name>driverClassName</name>
                        <value>com.microsoft.jdbcx.sqlserver.SQLServerDataSource</value>
                </parameter>
                
                <parameter>
                        <name>user</name>
                        <value>web</value>
                </parameter>
                
                <parameter>
                        <name>password</name>
                        <value>pass</value>
                </parameter>
                
                <parameter>
                        <name>url</name>
                        <value>jdbc:microsoft:sqlserver://192.168.1.71;databasename=DBOne</value>
                </parameter>
        </ResourceParams>

Tests are being conducted on the latest release candidate of Glassfish V2 (v2b58g).
Glassfish seems to be a great product and I'd really like to move this project towards this platform. Does anyone have any more information on this? A working example would be fantastic. Ideas would be appreciated.
[Message sent by forum member 'waylonflinn' (waylonflinn)]

http://forums.java.net/jive/thread.jspa?messageID=235480