Install glassfish4.0 on CentOS to configure jdbc connection to mysql

Source: Internet
Author: User
Unzip glassfish-4.0.zip1、decompress and install unzip unzipglassfish-4.0.zip cpcpglassfish4 & nb

Glassfish-4.0.zip

1. decompress the package and copy it to the specified installation path.

  Unzip glassfish-4.0.zip cp glassfish4/usr/local/-rf

2. set glassfish environment variables

  Vim/etc/profileexport GLASSFISH_HOME =/usr/local/glassfish4export PATH =.: $ PATH: $ JAVAHOME/bin: $ MYSQLHOME/bin: $ GLASSFISH_HOME/bin source/etc/profle

Go to/usr/local/glassfish4/glassfish/config and edit asevn under this directory. conf file, add AS_JAVA = "/usr/local/jdk" to the end of the file (the value is the local jdk installation path)

  AS_JAVA = "/usr/jdk1.7.0 _ 60"

 

3. if you do not want to use the default domain, you can create your own domain in this step and specify domaindir and admin port

Run the following command to create a domain named rainbow disk on port 4848.

  Asadmin create-domain -- adminport 4848 hongpan

Enter admin user name [Enter to accept default "admin"/no password]>

Bad Network Configuration. DNS can not resolve the hostname:

Java.net. UnknownHostException: dev: Name or service not known

Using port 4848 for Admin.

Using default port 8080 for HTTP Instance.

Using default port 7676 for JMS.

Using default port 3700 for IIOP.

Using default port 8181 for HTTP_SSL.

Using default port 3820 for IIOP_SSL.

Using default port 3920 for IIOP_MUTUALAUTH.

Using default port 8686 for JMX_ADMIN.

Using default port 6666 for OSGI_SHELL.

Using default port 9009 for JAVA_DEBUGGER.

Distinguished Name of the self-signed X.509 Server Certificate is:

[CN = localhost, OU = GlassFish, O = Oracle Corporation, L = Santa Clara, ST = California, C = US]

Distinguished Name of the self-signed X.509 Server Certificate is:

[CN = localhost-instance, OU = GlassFish, O = Oracle Corporation, L = Santa Clara, ST = California, C = US]

Domain hongpan created.

Domain hongpan admin port is 4848.

Domain hongpan allows admin login as user "admin" with no password.

Command create-domain executed successfully.

 

4. start the domain rainbow disk just created

  Asadmin start-domain hongpan

Waiting for hongpan to start .........................

Successfully started the domain: hongpan

Domain Location:/usr/local/glassfish4/glassfish/domains/hongpan

Log File:/usr/local/glassfish4/glassfish/domains/hongpan/logs/server. log

Admin Port: 4848

Command start-domain executed successfully.

 

5. modify the admin password of the domain you just created and enable you to log on to the console through the web.

  Asadmin change-admin-password

 

Enter admin user name [default: admin]>

Enter the admin password>

Enter the new admin password>

Enter the new admin password again>

Command change-admin-password executed successfully.

 

During each operation, the console prompts you to enter the user name and password, which is troublesome.

You can create a password configuration file.

AS_ADMIN_PASSWORD = xxxx

 

6. enable remote logon

  Asadmin enable-secure-admin

 

Enter admin user name>

Enter admin password>

You must restart all running servers for the change in secure admin to take effect.

Command enable-secure-admin executed successfully.

 

7. restart domain

  Asadmin restart-domain hongpan

Now you can manage it on the console.

 


 

 

Configure jdbc connection to mysql

1. copy the jar package connecting to mysql to the glassfish Library Directory.

1 cp mysql-connector-java-5.1.16-bin.jar /usr/local/glassfish4/glassfish/lib/

2. restart domain

 

3. log on to the mysql console and go to the JDBC connection pool interface.

 

Click new to create a JDBC connection pool

 

Configure connection properties

Test connectivity

Succeeded

 

4. create a JDBC resource. The program only needs to connect to the JNDI name at that time.

 

Set the JNDI Name and Pools Name to the created JDBC connection pool.

 

The configuration is complete!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.