users@glassfish.java.net

Re: RE: JNDI lookup, dependency injection, datasource

From: <glassfish_at_javadesktop.org>
Date: Tue, 15 Jun 2010 10:19:15 PDT

Though the returned DataSource is of type "javax.sql.DataSource" (com.sun.gjc.spi.jdbc40.DataSource40), application server will be internally using com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource.
You should cast it to "javax.sql.DataSource"

You can define the datasource-definition to be application scoped ie., with prefix "java:app/" so that the datasource is available for all modules and components within the application.

eg:
 @DataSourceDefinition(name = "java:app/env/Servlet_DataSource",
      minPoolSize = 0,
      initialPoolSize = 0,
      className = "org.apache.derby.jdbc.ClientXADataSource",
      user = "APP",
      password = "APP",
      databaseName = "testdb",
      properties = {"connectionAttributes=;create=true"}
   )
[Message sent by forum member 'jr158900']

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