Showing posts with label connection pool. Show all posts
Showing posts with label connection pool. Show all posts

Saturday, July 17, 2010

Configure MySQL Connection Pool in Glassfish V3

The MySQL connection pool in GlassFish V3, is actually as easy as it was in V2!

First of all, we need to download from www.mysql.com the latest jdbc driver:

http://dev.mysql.com/downloads/connector/j/5.1.html

Extract the downloaded archive and take the mysql-connector-java-x.x.x-bin.jar from the compressed archive and put it in {glassfish_installation}/glassfish/lib directory and restart glassfish (from {glassfish_installation}/glassfish/bin directory):

asadmin stop-domain domain1
asadmin start-domain domain1

Now we need to navigate to the administrator application:
http://localhost:4848/
 
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New'.
Fill in the Connection Pool 'Name' with a suitable name like MySQLPool.
Select 'Resource Type' : 'javax.sql.DataSource'.
Select 'Database Vendor' : 'MySQL'.
Select 'Next'.

At the next page go down at the additional Properties.
Find and edit the following properties :
Fill in property 'User' with the 'Value' : {db_user}
Fill in property 'Password' with the 'Value' : {db_user_pass}
Fill in property 'URL' with the 'Value' :
jdbc:mysql://[host]:[port]/[database name]
Select 'Finish'.

Navigate to Connection Pools and select the pool you just created.
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.

Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.
Fill the JNDI Name like 'jdbc/myconnnection'.
Select from 'Pool Name' combo box the pool we just created.
And select 'OK'.

The Connection Pool is ready!


p.s.
You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.

Sunday, January 10, 2010

GlassFish and Toplink ( ..continued )

My experience with GlassFish has increased since my last post.

There is already an ADF Faces - JPA eclipselink application that runs smoothly now for a few weeks on GlassFish. The only problem that came up after the successful code tests, was the Connection Pool leakage. There are some differences between the OAS and the GlassFish Connection Pooling. As a result, I had to tweak the preferences a little. In the 'General' tab I disabled the 'Connection Validation Required' checkbox to save time on connection gets. Also, at the 'Advanced' tab I set the 'Leak Reclaim' to true and the 'Leak Timeout' to 120 secs. The leak timeout may vary depending on the application. These two tweaks have stabilized the application.

The other important thing that I need to mention, is the difficulty that I found in installing two different versions of toplink. So the workaround is to install a new GlassFish installation for every toplink version (because the toplink libraries are installed in the installations's lib directory). I am lucky to have only two toplink versions (10.1.3.5 and 10.1.3.3) to handle!

But it is a serious thing to be considered in the following GlassFish versions: The library loader per version and the grouping of libraries. It is the one thing that I miss OAS for!


p.s.
You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.

Tuesday, December 15, 2009

Firebird Connection Pool in Glassfish 2.x.x

We will create in a few easy steps a Firebird Connection Pool on GlassFish 2.1.1.

First of all, we need to download the latest jdbc driver from:

http://www.firebirdsql.org/index.php?op=files&id=jaybird

Extract the downloaded archive and take the jaybird-full-x.x.x.jar from the compressed archive and put in {glassfish}/lib directory and restart glassfish:

asadmin stop-domain domain1
asadmin start-domain domain1

Now we need to navigate to the administrator application:
http://localhost:4848/
 
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.
Fill in the Connection Pool 'Name'.
Select 'Resource Type' : 'javax.sql.ConnectionPoolDataSource'.
Select 'Next'.

At the next page complete the 'Datasource Classname' with :

org.firebirdsql.pool.sun.AppServerConnectionPoolDataSource

Then go down at the additional Properties.
Find and edit the following properties :
Select 'Name' : 'userName' and 'Value' : {db_user}
Select 'Name' : 'password' and 'Value' : {db_user_pass}
Select 'Name' : 'databaseName' and 'Value' : {host_name}:{db_path}
for example:
localhost:/my_data_files/mydb.fdb
Select 'Finish'.

Navigate to Connection Pools and select the pool you just created.
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.

Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.
Fill the JNDI Name like 'jdbc/myconnnection'.
Select from 'Pool Name' combo box the pool we just created.
And select 'OK'.

The Connection Pool is ready!


p.s.
You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.

Monday, December 14, 2009

Create Postgresql Connection Pool in Glassfish 2.x.x

We will create a PostgreSQL (8.4) Connection Pool on a GlassFish 2.1.1 [and GlassFish v3].

First of all, we need to download the latest jdbc driver:

http://jdbc.postgresql.org/download.html

Copy the downloaded archive postgresql-x.x.-xxx.jdbc4.jar in {glassfish}/lib directory and restart glassfish:

asadmin stop-domain domain1
asadmin start-domain domain1

Now we need to navigate to the administrator application:
http://localhost:4848/
 
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.
Fill in the Connection Pool 'Name'.
Select 'Resource Type' : 'javax.sql.DataSource'.
Select 'Database Vendor' : 'PostgreSQL'.
Select 'Next'.

At the next page go down at the additional Properties.
Find and edit the following properties :
Select 'Name' : 'User' and 'Value' : {db_user}
Select 'Name' : 'Password' and 'Value' : {db_user_pass}
Select 'Name' : 'DatabaseName' and 'Value' : {db_name}
Select 'Name' : 'ServerName' and 'Value' : {server_hostname}
If your dqatabase is not in the default port (5432) you might also need to edit the following attribute :
Select 'Name' : 'PortNumber' and 'Value' : {port_number}
Select 'Finish'.

Navigate to Connection Pools and select the pool you just created.
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.

Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.
Fill the JNDI Name like 'jdbc/myconnnection'.
Select from 'Pool Name' combo box the pool we just created.
And select 'OK'.

The Connection Pool is ready!


p.s.
You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.

Mysql Connection Pool in GlassFish 2.x.x

As a followup to a previous post, regarding the creation of an oracle connection pool in GlassFish 2.1.1, we will create a MySQL connection pool.

First of all, we need to download from www.mysql.com the latest jdbc driver:

http://dev.mysql.com/downloads/connector/j/5.1.html

Extract the downloaded archive and take the mysql-connector-java-x.x.x-bin.jar from the compressed archive and put in {glassfish}/lib directory and restart glassfish:

asadmin stop-domain domain1
asadmin start-domain domain1

Now we need to navigate to the administrator application:
http://localhost:4848/
 
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.
Fill in the Connection Pool 'Name'.
Select 'Resource Type' : 'javax.sql.DataSource'.
Select 'Database Vendor' : 'MySQL'.
Select 'Next'.

At the next page go down at the additional Properties.
Find and edit the following properties :
Select 'Name' : 'User' and 'Value' : {db_user}
Select 'Name' : 'Password' and 'Value' : {db_user_pass}
Select 'Name' : 'URL' and 'Value' :
jdbc:mysql://[host]:[port]/[database name]
Select 'Finish'.

Navigate to Connection Pools and select the pool you just created.
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.

Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.
Fill the JNDI Name like 'jdbc/myconnnection'.
Select from 'Pool Name' combo box the pool we just created.
And select 'OK'.

The Connection Pool is ready!


p.s.
You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.

Monday, December 7, 2009

Oracle Connection Pool in GlassFish 2.x.x

Glassfish does not ship with oracle jdbc drivers. The oracle driver needs to be added manually.  The driver can be found either in a JDeveloper or oracle client or database installation in {install_path}/jdbc/lib, or from oracle's site:

http://www.oracle.com/technology/software/tech/java/sqlj_jdbc/htdocs/jdbc_10201.html

Glassfish needs at least ojdbc14.jar to work properly. Older drivers do not work. Put the ojdbc14.jar in {glassfish}/lib directory and restart glassfish:

asadmin stop-domain domain1
asadmin start-domain domain1

Now you need to navigate to the administrator application:
http://localhost:4848/
 
Open the 'Resources' -> 'JDBC' -> 'Connection Pools' and select 'New.
Fill in the Connection Pool 'Name'.
Select 'Resource Type' : 'javax.sql.ConnectionPoolDataSource'.
Select 'Database Vendor' : 'Oracle'.
Select 'Next'.

At the next page go down at the additional Properties.
Select all the properties and select 'Delete Properties'.
Select 'Add Property', fill 'Name' : 'user' and 'Value' : {db_user}
Select 'Add Property', fill 'Name' : 'password' and 'Value' : {db_user_pass}
Select 'Add Property', fill 'Name' : 'url' and 'Value' :
jdbc:oracle:thin:@[host][:port]:SID
or
jdbc:oracle:thin:@//[host][:port]/SID
Select 'Finish'.

Navigate to Connection Pools and select the pool you just created.
Click Ping to test that it is working. If it is not, it is probably because you have mistyped the connection credentials. Go to 'Additional Properties' tab of the connection pool detail page and correct any errors. Try ping again.

Open the 'Resources' -> 'JDBC' -> 'JDBC Resources' and select 'New.
Fill the JNDI Name like 'jdbc/myconnnection'.
Select from 'Pool Name' combo box the pool we already created.
And select 'OK'.

The Connection Pool is ready!


p.s.
You can find me on fiverr for more personalized requests on any java app server configuration problem or java error that you encounter, with deliverance of less than a day (true!) and money back guarantee if not satisfied.