JDBC Connection Pool
This guide has been reviewed and reformatted for Ruk-Com Cloud PaaS. Screens may vary slightly by platform version.
Click or tap a screenshot to view it at its original size.
Objective
This guide explains how to use JDBC Connection Pool on Ruk-Com Cloud PaaS, with ordered procedures and practical verification points.
Before you begin
- Sign in with an account permitted to manage the relevant environment.
- Confirm the target environment, region and resources before saving changes.
- Create a backup or rollback plan before changing a production system.
Connection Pools in JDBC (Java Database Connectivity) are a feature for optimizing caches and database connections. This allows for reusability. Instead of having to create or close each request individually, ie.
- There is no JDBC Connection Pool.–Open connections to the database service as needed and close them when the page has finished processing requests.
- JDBC Connection Pool – Keeps the connection pool open, so if a page needs to access the database It would just be using an existing connection. (A new one will be created only if there was no previous connection.)
Setting up a JDBC Connection Pool for your application server can reduce the delay and resource consumption of servicing each request individually. In such a way, it enhances the efficiency of the database. (especially for requests to dynamic database-driven applications
However, bothGlassFishandPayaraJava application servers provide native support for pooling mechanisms to optimize database access.
Follow the simple steps below to set up your JDBC Connection Pool connection.
Creating the Environment
1. Log in with your Ruk-Com Cloud account.
2. Press the buttonNew environment

3. In the sectiontopology wizard Switch to the Java tab, selectGlassFishorPayaraFollow your server application and add whatever is required to the database (in the example we useGlassFishand MySQL together) Next, set the Container's resource limits and name the desired environment.

Press Create, wait a moment for the new environment to appear and continue creating the JDBC connection pool.
Preparing the Environment
1. Press the buttonOpen in Browser forMySQL node

Use the email received with the database details to log in to open the panel.phpMyAdmin
2.When you first come in Switch to the tab.User accountsand click on the linkAdd user accountOn the page that opens, fill in the required information in the form and check the Create database with same name and grant all privileges option.

Setting up Application Server
1.The MySQL JDBC connector is defaulted to a stack (located in the/opt/glassfish/glassfish/domains/domain1/lib on the serverGlassFishyours or /opt/payara/glassfish/domains/domain1/lib onPayara), so you don't need to upload it manually.

2. Log in to the GlassFish (or Payara) admin panel using the details received from the email.

3. Go to the sectionResources > JDBC > JDBC Connection Poolsand click the new button on the tool panel in the form that appears. Please fill in the information as follows.
- Pool Name - Set a name as desired.
- Resource Type - Select javax.sql.DataSource from the list.
- Database Driver Vendor – Select MySQL.

Press the next button to continue.
4. Find and edit the sectionAdditional Propertiesas follows
- User- Section that provides login into the database (in our case pooling)
- ServerName– Specify your database host without the protocol (e.g. node166355-gf-pooling.jelastic.com).
- Port- Set the port number to 3306.
- DatabaseName- The part to set the database name (in our case pooling)
- Password- For storing passwords as specified by users
- URLandUrl- Set the connection string of JDBC in jdbc:mysql://{db_host}:3306/ format; In this place, channel{db_host}It can be replaced with another node's hostname (node166355-gf-pooling.jelastic.com) or IP address. (192.168.2.57)

After specifying the various properties, click Finish.
5. In order to check access Select the pool connection you just created and press the Ping button if everything goes smoothly. You will see a message pop up saying Ping Succeeded.

6. Go to the sectionResources > JDBC > JDBC Resourcesand select the New button to create a JDBC resource for pooling. In the window that opens, enter the JNDI Name and select the Pool Name from the list.

Confirm resource creation by pressing the OK button above.
Java code connection
Place this code in the Java class section of your application code.

This is the gap section.{resources} is replaced by name.of the previously created JNDI (e.g. jdbc/mypool in our case).
You can now deploy your Java applications to Ruk-Com Cloud and enjoy the benefits of GlassFish and Payara Micro connection pooling.