GlassFish4安装部署
来源:互联网 发布:linux ed2k下载工具 编辑:程序博客网 时间:2024/05/31 13:15
http://www.oracle.com/technetwork/cn/java/javase/downloads/index.html 下载Javase(JDK)并安装
1.下载
http://www.oracle.com/technetwork/cn/java/javaee/downloads/index.html(oracle官方ZIP版)
https://glassfish.java.net (社区ZIP版)
http://www.oracle.com/technetwork/java/javaee/downloads/java-ee-7-sdk-with-jdk-u45-2066865.html
(安装包版本-它不用安装javaseJDK)
2.安装
解压下载的Glassfish(.zip包)即可,如解压在d:\盘根目录下。
3.启动
D:\glassfish4\glassfish\bin\startserv.bat 双击startserv.bat文件会自动启动glassfish服务(stopserv.bat是停用服务)
①http://localhost:8080 这个地址是http端也就是主页
②http://localhost:4848 这个地址是后台配置端,默认没有密码,直接登录
④修改admin密码
⑤开启远程后台访问
①热部署:将NetBeans打包好的.war包,复制到(D:\glassfish4\glassfish\domains\domain1\autodeploy)目录下即可,Glassfish会自动部署
②web部署:http://localhost:4848在这里面部署(区分war包部署与文件夹部署)
6.连接池设置
①将JDBC驱动复制到安装目录下(如:D:\glassfish4\glassfish\lib),复制完后,要重启一下glassfish服务才生效
②创建JDBC连接池
③创建JDBC资源
④在web项目中使用连接池
(1)创建连接池类
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;
public class Pool {
private static DataSource ds = null;
static//在静态代码块中创建数据库连接池
{
try
{
Context initCtx = new InitialContext();//JNDI初始上下文
ds = (DataSource) initCtx.lookup("sjk_pool");//检索st指定的对象,并返回绑定到st的对象DataSource获取连接
}
catch (Exception e)
{
throw new ExceptionInInitializerError(e);
}
}
public static Connection getConnection() throws SQLException
{
return ds.getConnection();//从数据源中获取数据库连接
}
public static void release(Connection ct,PreparedStatement ps,ResultSet rs)//释放资源
{
try
{
if(rs!=null)
{
rs.close();
}
if(ps!=null)
{
ps.close();
}
if(ct!=null)
{
ct.close();
}
}
catch (SQLException ex)
{
ex.printStackTrace();
}
}
(2)在其他类使用
Connection ct;
PreparedStatement ps;
ResultSet rs;
try{
ct = Pool.getConnection();
ps = ct.prepareStatement("select name from users where Code=? and Password=? ");
ps.setString(1,username);
ps.setString(2,password);
rs = ps.executeQuery();
..........
.........
}
catch(SQLException ex){
ex.printStackTrace();
}
finally{
Pool.release(ct,ps,rs);
}
- GlassFish4安装部署
- centos 6.5下安装glassfish4
- Glassfish4.1安装及配置
- GlassFish4 deploy 部署应用 快速入门
- glassfish4和MyEclipse Blue
- glassfish4+mod_jk集群搭建
- GlassFish4 集群配置 linux
- glassfish4.0配置
- glassfish4 配置数据库连接池
- glassfish4系统启动脚本
- glassfish4新特性
- glassfish4.1 简单操作
- glassFish4 log输出开启、关闭
- 安装部署
- 安装部署
- 部署安装
- GlassFish4 的admin默认密码为空
- Glassfish4.1和Tomcat配置Https访问
- php通过xpath解析xml数据
- Linux几种网络连接模式
- 使用freemarker(FTL)常见语法 总结
- UEFI BIOS模式下Windows系统启动过程以及引导文件修复方法
- struts2入门
- GlassFish4安装部署
- leetcode-27-Remove Element
- LCP014 LeetCode 14. Longest Common Prefix
- 安卓手机本地生成二维码,可以在中间加上icon
- oracle学习(四)--数字型number
- 17.JVM垃圾回收分代收集算法
- TDDL:来自淘宝的分布式数据层
- lucence 文档评分公式
- 自定义圆