Configuring MySQL in glassfish

Application Server Version: GlassFish Server Open Source Edition 3.1.1 (build 12)


1. Download mysql JDBC driver here.

2. Extract the zip and copy the “mysql-connector-java-5.1.17-bin” jar to “%GLASSFISH_INSTAL_DIR%/lib” folder.

3. Re-start glassfish server.

4. Then create JDBC connection pool.



7.  Fill in atleast the below details in the property table.

  • DatabaseName (e.g. webchat)
  • Password (e.g. root)
  • URL (e.g. jdbc:mysql://localhost:3306/webchat)
  • Url (e.g. jdbc:mysql://localhost:3306/webchat)
  • ServerName (e.g. localhost)
  • User (e.g. root)

8. After the Step 7 is completed, the configuration of connection pool is done. After this “MySQL” should show as below:

9. Test the connectivity by clicking ping. Below snippet shows a successful connection :

10. Next step is to create a JNDI binding for this connection.


12. With completion of this step, MySQL connection is bound with JNDI name “jdbc/mysqlwebchat”.