在centos7上为Jetty配置c3p0-mysql连接池.
来源:互联网 发布:北京现代软件学院骗局 编辑:程序博客网 时间:2024/06/15 11:34
一共需要改三处:
- 修改Jetty的配置文件.
- 修改项目的web.xml使依赖c3p0连接池.
- 配置好环境.
进入正题:
首先下载安装Jetty.
然后修改 JETTY_HOME/etc/jetty.xml文件追加如下内容:
<New id="DSTest" class="org.eclipse.jetty.plus.jndi.Resource"> <Arg></Arg> <Arg>jdbc/DSTest</Arg> <Arg> <New class="com.mchange.v2.c3p0.ComboPooledDataSource"> <Set name="driverClass">com.mysql.jdbc.Driver</Set> <Set name="jdbcUrl">jdbc:mysql://localhost:3306/mysql</Set> <Set name="user">root</Set> <Set name="password">123456</Set> </New> </Arg></New>
然后修改项目里的web.xml,追加代码:
<resource-ref> <description>My DataSource Reference</description> <res-ref-name>jdbc/DSTest</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth></resource-ref>
两个xml文件都修改了,然后应该配置运行时的环境:
安装mysql,刚安装完时不需要用户名密码直接输入
[root@centos7 etc]# mysql
然后为root用户添加一个123456的密码:
use mysql;update user set password=PASSWORD("123456") where user='root';
mysql已经配置完了,然后应该将需要的jar包放在jetty服务器上:
//切换到jetty依赖的扩展包的所在的文件夹.[root@centos7 etc]# cd JETTY_HOME/lib/ext//下载c3p0需要依赖的jar包.[root@centos7 etc]# wget http://repo1.maven.org/maven2/c3p0/c3p0/0.9.1.2/c3p0-0.9.1.2.jar//然后你需要将一个mysql驱动包也拷贝到此文件夹.比如 mysql-connector-java-3.1.12-bin.jar
**然后将war包放入jetty的webapps里面.**
现在只需要重启jetty服务器就可以了.
重启jetty可以使用:
[root@centos7 etc]# cd JETTY_HOME/bin[root@centos7 etc]# ./jetty.sh stop[root@centos7 etc]# ./jetty.sh -d start
如果想确认可以使用jconsole.exe查看信息.
阅读全文
0 0
- 在centos7上为Jetty配置c3p0-mysql连接池.
- Mysql配置Spring配C3P0连接池
- c3p0连接池在spring中的配置
- 在websphere上配置mysql连接池
- 在websphere上配置mysql连接池
- Spring配C3P0连接池(以MySQL数据库配置为例)
- c3p0在hibernate连接配置
- c3p0 连接池配置
- C3P0连接池配置
- C3P0连接池配置
- c3p0 连接池配置
- c3p0连接池配置
- C3P0连接池配置
- C3P0连接池配置
- C3P0连接池配置
- c3p0连接池配置
- C3P0连接池配置
- c3p0连接池配置
- Nignx负载,项目层面无法获取浏览器头部信息
- #pragam comment
- masonry使用方法,masonry布局多控件横向或纵向一次性布局
- JPA 级联标签的解释 @Cascade
- slf4j初始化绑定源码分析
- 在centos7上为Jetty配置c3p0-mysql连接池.
- mac 编译ffmpeg真简单!
- 【LeetCode】419. Battleships in a Board
- 原型扩展1.2.7
- nginx模块开发实战
- 小程序的模态框和提示框
- Visual studio 2017中 Javascript无法智能提示的解决办法
- 判断今天是星期几 暴力枚举
- Retrofit各个注解的含义及作用