CentOS安装glassfish4.0配置jdbc连接mysql

分类:CentOS教程 阅读:37996 次

版本glassfish-4.0.zip

1、解压,拷贝到指定安装路径

2、设置glassfish环境变量

进入/usr/local/glassfish4/glassfish/config,编辑该目录下的asevn.conf文件,在文件末尾加入AS_JAVA="/usr/local/jdk"(值为本机jdk安装路径)

3、如果不想使用默认domain可在此步骤创建自己的domain,并指定domaindir和admin port

执行如下命令,创建端口为4848,名称为虹盘的domain

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

Bad Network Configuration. DNS can not resolve the hostname:

java.net.UnknownHostException: dev: 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、启动刚才建立的domain虹盘

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、修改刚刚创建的domain的admin密码,并使之能够通过web登录到控制台

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.

每次操作的时候控制台都提示输入用户名密码,比较麻烦

可以建立密码配置文件

AS_ADMIN_PASSWORD=xxxx

6、开启远程登录权限

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、重启domain

现在就可通过控制台进行管理了

CentOS安装glassfish4.0配置jdbc连接mysql

下面开始配置jdbc连接mysql

1、拷贝连接mysql的jar包到glassfish库目录里

2、重启domain

3、登陆mysql控制台,到JDBC连接池界面

CentOS安装glassfish4.0配置jdbc连接mysql点击new新建JDBC连接池

CentOS安装glassfish4.0配置jdbc连接mysql配置连接属性

CentOS安装glassfish4.0配置jdbc连接mysql测试连通性

Succeeded

4、创建JDBC资源,程序到时候只需要连接JNDI名称即可

CentOS安装glassfish4.0配置jdbc连接mysql
下图JNDI Name填写名称,Pools Name选择刚才创建的JDBC连接池。

CentOS安装glassfish4.0配置jdbc连接mysql
配置完成,大功告成!