using a new JDBC-Database in Glassfish

During the deployment of our application from Websphere to Glassfish, I had to
deploy a MySQL driver to use the database.

  • Providing the JDBC Driver in the Glassfish-environment

For the access to a MySQL-database you have to deploy the JDBC-driver.

You have to copy the jar archive of the JDBC driver into the directory

/domains/domain1/lib/ext
and restart the app server with:

/bin/asadmin stop-domain domain1
/bin/asadmin start-domain domain1


  • creating a JDBC Connection Pool

to access the database a connection pool must be created first.
go to the administration page of Glassfish : ''http://:4848'' .
Use the menue "Resources - JDBC - Connection Pools" with the following data:

Name PoolName
Resource Type javax.sql.DataSource
Database Vendor MySQL

AsDatasource Classname use the default com.mysql.jdbc.jdbc2.optional.MysqlDataSource.

The properties:

databaseName
user
password
portNumber 3306
servername localhost

In the General tab you can use the button "Ping" for testing the database access.

  • Configure the JDBC Resource for an application

Menue Resource - JDBC - JDBC Resource to create a new resource:

JNDI-Name
PoolName created poolname
Description usage of this resource
Status is the resouce available?


Now you can access the connection via a JNDI Lookup