Java EE 5 samples integarte well with mysql database
- Install the application server out of the bundle which includes MySQL.
- Start MySQL DB.
Refer this install guide for information on how to start MySQL server. - login to MySQL data base as root
grant all privileges on *.* to 'dbuser'@'localhost' identified by 'dbpassword';
One can be more specific while granting privileges to restrict the scope of access. In addition, the values used for user 'dbuser' and password 'dbpassword' are suggestive, you are free to change them but make sure they are referred appropriately in jdbc connection pool. - Start the application server and connect to it through a browser at admin port 4848.
create jdbc connection pool using the node Resources/JDBC/Connection PoolsName: mysqlPool Resource Type: javax.sql.DataSource Database Vendor: mysqlclick on next and define the following properties
databaseName: test user: dbuser password: dbpassword Url: jdbc:mysql://localhost:3306/test URL: jdbc:mysql://localhost:3306/testThe default port for MySQL is 3306. If it is different, replace the port 3306 with the correct port number.
- Crate jdbc resource using the node Resources/JDBC/JDBC Resources
JNDI Name: jdbc/mysql Pool Name: mysqlPool - Deploy the attached war file jsf-jpa-war.war whose ./src/conf/persistence.xml uses jdbc/mysql
For more information on the jsf-jpa-war sample, please refer to sample documentation.This is a part of the Java EE 5 samples bundle which can be downloaded from https://glassfish-samples.dev.java.net/
- Verify the working of deployed war by connecting to localhost:8080/jsf-jpa-war Related Topics >>Blog Links >>
- Login or register to post comments
- Printer-friendly version
- msreddy's blog
- 1700 reads





