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
/xxx
dw
:wq

Followers

Pageviews Last 7 Days