JNDI Data Source Setup in Glassfish Server: Enter Connection Pool Details

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

JNDI Data source Setup in Glassfish Server

JNDI Data source Setup in Glassfish Server


1. Before you start JNDI setup, Create database in Mysql Server
Example: my database name is nvPortal.
2. Download MySql connector jar file. Exp: mysql-connector-java-5.1.18-bin.jar
3. Copy mysql-connector jar file into your local glassfish server domains lib folder location
example : C:\glassfish4\glassfish\domains\domain1\lib\
4. Restart the glassfish server.
5. Open glassfish Server Administrator consol
Go to ----> Resources -----> JDBC ----- > JDBC Connection Pools
6. Create New JDBC Connection Pool
---- > Click new button to displays following window

Enter Connection Pool details:

Pool Name: nvPool


Resource Type: select javax.sql.Datasorce from dropdown list.
Database Diver Vendor: select diver vendor MySql from dropdown list.

[email protected]
JNDI Data source Setup in Glassfish Server

7. click next to shows the following window:


a. You can change default Pool settings as per your requirement shows in
below window. Like Initial and Minimum Pool Size, Maximum Pool Size, Pool
Resize Quantity, Idle Timeout, Max Wait Time.

b. Enter Your Local MySql database connection details:


User: root
Password: root
Database Name: nvPortal
Url: jdbc:mysql://localhost:3306/nvPortal

[email protected]
JNDI Data source Setup in Glassfish Server

8. Click finish to create nv Connection Pool. nvPool shows in connection pool list

9. Click on nvPool to displays the below window -----> Click on --- > Ping button.
a. If database connection details are correct, message displays Ping Succeeded.
Your Connection pool is created successfully. It shows following window.

[email protected]
JNDI Data source Setup in Glassfish Server

b. If database connection details are not correct, message displays An error has
occurred. It shows the following error window. Check your User Name,
Password, database Name and Connection URL.

10. Create JDBC Resources.


a. Go to ----> Resources -----> JDBC ----- >JDBC Resources

b. Click to New button to displays following window

[email protected]
JNDI Data source Setup in Glassfish Server

Enter JDBC resource Details:


JNDI Name: jdbc/nvPortal
Pool Name: Select nvPool from drop down list.
Click Ok to create JDBC Resources successfully. Jdbc/nvPortal shows
in JDBC resources.

[email protected]
JNDI Data source Setup in Glassfish Server

*** Note: Jdbc/nvPortal name and in your spring application ----> /WEB-INF/etc/conf/jndi-dao-
nvPortal-config.xml file contains JNDI name should be same.

Example: in jndi-dao-nvPortal-config.xml

<jee:jndi-lookup id="portalJNDI" jndi-name="jdbc/nvPortal"/>

[email protected]

You might also like