GlassFish MySql connection pool with empty password

The default mysql database server password is empty, which is convenient in development mode, but turns out to be trouble when creating a jdbc connection pool in GlassFish. There seems to be no way to specify an empty password either in admingui or asadmin.

One workaround is to use a temporary password (say, "xxx") when creating the connection pool, stop the domain, open $GLASSFISH_HOME/domains/domain1/config/domain.xml, and replace "xxx" with ""

This should work with all versions of GlassFish (v1, v2, and v3). To do it with script:

$GLASSFISH_HOME/bin/asadmin start-domain

$GLASSFISH_HOME/bin/asadmin create-jdbc-connection-pool --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlXADataSource --property user=root:password=xxx:DatabaseName=test:ServerName=localhost:port=3306 mysql-pool
$GLASSFISH_HOME/bin/asadmin create-jdbc-resource --connectionpoolid mysql-pool jdbc/test

$GLASSFISH_HOME/bin/asadmin stop-domain

cd $GLASSFISH_HOME/domains/domain1/config
cat domain.xml | sed "s/xxx//" > domain.xml.replaced
mv domain.xml domain.xml.original
mv domain.xml.replaced domain.xml

$GLASSFISH_HOME/bin/asadmin start-domain
vi/vim is also well suited for this type of search-replace:
vim domain.xml


vitamine k said...

Setting an empty value for the connection pool. While creating the pool in GUI, I do not face a trouble creating the pool with an empty password. But while pinging or setting a password with empty string, i get the "No Password Credential found" and "Property password cannot be removed" errors respectively. The access denied is got as there are no privileges for the user. You should try to grant privileges using

Steve Smith said...

Great and Useful Article.

Online Java Training

Java Online Training India

Java Online Course

Java EE course

Java EE training

Best Recommended books for Spring framework

Java Interview Questions

Java Course in Chennai

Java Online Training India