Create a data source (Create a database connection pool) and a glassfish connection pool in glassfish
1. Enter http: // localhost: 4848 in the browser to log on to the glassfish Domain Management Console. The default username and password are amin and adminadmin. (You can also right-click the NetBeans service tab -- server -- GlassFishServer -- to view the Domain Management Control Center)
2. Create a database connection pool;
3. Create a jdbc resource. Enter the JNDI name and select the newly created connection pool.
Of course, if you use NetBeans, there is a simple method. When you generate an object class through the database, ide will prompt you to create a data source step by step.Select package -- Right-click Create, generate object class through database -- create data source -- enter the JNDI name and create database connection. Of course, the database driver should be placed under the domain in glassfish.