« Datenbankdesign | Main | Umzugspause »

HOWTO: JSAS(Glassfish) with MySQL (update)

If you get this errormessage on pinging your database from within the admin console....

"Operation 'pingConnectionPool' failed in 'resources' Config Mbean. Target exception message: Class name is wrong or classpath is not set for : com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource"

....then your jdbc-driver for mysql is missing!

get the jdbc-driver for MySQL here:

Move the file "mysql-connector-java-5.1.5-bin.jar" to the directory "%J2EE_HOME%\domains\domain1\lib\ext\"

(Re)Start the Application Server and create a new connection pool:
Common Tasks > Create New JDBC Connection Pool
I used following settings:
- Name: mysqlpool
- Resource Type: javax.sql.DataSource
- Database Vendor: mysql

- Data Source Class Name: com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource

- serverName: (just the localhost)
- port: 3306 (default port)
- user: (an existing user allowed to connect to your mysql db)
- password: (the users password)
- databaseName: (the name of the database you want to connect to)

Ping succeeded! Yay!

To use your new connection pool, just add a JDBC Resource and use its name in the persistence.xml for the DataSource like this:


Set only necessary options. If you get "No Database selected", try to delete the "url"-property or follow this advise:

When creating the connection pool DataSource properties, delete the “Url” property, and set the “URL” property. The URL may contain ?user=user&password=password, or you may leave them out and set “user” and “password” properties instead. These correspond to setURL(), setUser() and setPassword() on com.mysql.jdbc.jdbc2.optional.MysqlDataSource.

If you omit the URL property, you will get:

java.sql.SQLException: No database selected

Infos about properties: http://docs.sun.com/app/docs/doc/819-3658/6n5s5nklk?a=view#gbsok

Comments (2)



merci pour toute réponse:

GlassFish création d'un pool pour sql_server 2000.

Mes salutations les plus respectueuses.

Gerald Schenke:

I dont know anything about sql_server 2000, if that was a question in your comment...
My translation of your comment makes no sense anyway...


This page contains a single entry from the blog posted on 29.10.07 15:54.

The previous post in this blog was Datenbankdesign.

The next post in this blog is Umzugspause.

Many more can be found on the main index page or by looking through the archives.

Powered by
Movable Type 3.31