Creating datasources and a connection pool

To create a datasource and a connection pool to help you use databases in your project, edit the $GLASSFISH_HOME/glassfish/domains/[domain_name]/config/domain.xml file. Inside the <resources> node, insert a child node like this one:

<jdbc-connection-pool 
pool-resize-quantity="4"
max-pool-size="64"
max-wait-time-in-millis="120000"
driver-classname="com.mysql.jdbc.Driver"
datasource-classname="com.mysql.jdbc.jdbc2.optional
.MysqlDataSource"
steady-pool-size="16"
name="MysqlPool"
idle-timeout-in-seconds="600"
res-type="javax.sql.DataSource">
<property name="databaseName" value="database"></property>
<property name="serverName" value="[host]"></property>
<property name="user" value="user"></property>
<property name="password" value="password"></property>
<property name="portNumber" value="3306"></property>
</jdbc-connection-pool>
<jdbc-resource pool-name="MySqlDs" jndi-name="jdbc/MySqlDs">
</jdbc-resource>

Then, look for this node:

<server config-ref="server-config" name="server">

Add this child to it:

<resource-ref ref="jdbc/MySqlDs"></resource-ref>

The example targets MySQL, so you will need to perform some changes for another database. Of course, you will also need to change the other parameters according to your needs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.58.51.36