-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Arttu,

On 10/1/2011 6:04 PM, Arttu Tanner wrote:
> Ok, figured it out. I needed to use InitialContext.lookupLink()
> instead of InitialContext.lookup() what I was using before.

That should not be necessary. Here is the code I have been using for
years using MySQL Connector/J and Tomcat 5.5, 6.0, and 7.0:

        // dataSourceName looks like java:/comp/env/jdbc/myDataSource
        Context context = new InitialContext();
        DataSource ds = (DataSource)context.lookup(dataSourceName);
        if(null == ds)
            throw new NamingException("Found no DataSource for '"
                                      + dataSourceName + "'");
        return ds.getConnection();

It's best to define everything in META-INF/context.xml. Then you don't
need anything anywhere else.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk6J6j4ACgkQ9CaO5/Lv0PBC+ACdHIk6h7Jj2oHN+i+rbsAOhJvd
goMAni7mcKwcdp66b90/SNGXqndw8N/y
=bNIC
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to