JDBC Connection Pool In Payara Using phpMyAdmin (MySQL)
In this article, we will learn how to create a JDBC connection pool in PHPMyAdmin.
Join the DZone community and get the full member experience.Join For Free
In this article, we will learn how to create a JDBC connection pool in phpMyAdmin.
Go to the database and create a new database. (I have created a database and table for your reference, you can use your own database and tables.)
In StudentDB, create a table tblStudent.
Generate the structure of the table.
For opening the Payara server, we have two options.
1) Go to netbeans>Services>Payara server>View Domain Admin Console
2) Go to any web browser (chrome, firefox, etc.)>Enter URL>http://localhost:4848/
(By default, the port number for Payara is 4848. If you have changed the port number of Payara Server, then use that port number)
Once Payara is open, go to Resources>JDBC>JDBC connection pool>New
Pool Name: You can provide any name.
For Resource type and Database Driver Vendor, you need to check the version: MySQL-connector-java.
A path for MySQL -connector-java: (path where you have installed the payara) >payara5>glassfish>domains>domain1>lib
If a version of MySQL-connector-java is less than 8, then use:
Resource Type: javax.sql.DataSource
Database Driver Vendor: MySql
If the version of MySQL-connector java is 8 or higher then use:
Resource Type: javax.sql.PoolDataSource
Database Driver Vendor: MySql
Once you click next, the second textbox of Database Driver Vendor will become writable.
In second textbox of DatabaseDriver Vendor write: com.mysql.cj.jdbc.MysqlDataSource.
Don't forget to check Introspect. It will give a long list of the property, but not checking introspect will give an error during ping.
Click next and scroll down. There will be a long list of properties for which you have to set the following property.
We need to add one property:
1) driverClass: com.mysql.jdbc.Drive.
You can sort property for faster access using two triangles. (Highlighted in the screenshot).
2) Password: It is your phpMyAdmin password (Setting password is compulsory. If your phpMyAdmin has a null password, set a password of phpMyAdmin.)
3) User: It is a username of phpMyAdmin.
4) Port: Port number of phpMyAdmin. In most cases, it is 3306.
5) ServerName: It is phpMyAdmin serverName.
6) DatabaseName: Provide a database name for which you are creating a connection pool.
7) URL: You can manually specify a URL or, as an alternative, you can perform steps 8 and 9.
Step: 8 (Optional)
Go to netbeans>services>Database>MysqlServer>Right click>connect
Step: 9 (Optional)
Select the database>Right click>connect.
One URL for a specific database will be created.
Copy until the name of the database and paste it into the URL, Url, url property.
Once all properties are set, click finish.
Click Save>New value successfully saved message will be shown.
Click ping>Ping succeeded.
Ping succeeded means a connection pool is created successfully.
Once the connection pool has succeeded, create a new JDBC resource>new.
JNDI Name: Provide any JNDI name. Pool Name: Select the pool we have created. Click OK.
A connection pool has been created! If you have any doubts or questions, feel free to ask in the comments section!
Opinions expressed by DZone contributors are their own.