« 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:
http://dev.mysql.com/downloads/connector/j/5.1.html

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
[NEXT]

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

- serverName: 127.0.0.1 (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)
[FINISH]

[PING]
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:

<jta-data-source>%JNDI_NAME%</jta-data-source>

UPDATE:
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)

Lotfi:

salut;

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...

About

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