jetty jndi mysql_jetty配置jndi数据源

1.下载jetty服务器(8.1.0.RC2),解压到任意目录下

http://dist.codehaus.org/jetty/jetty-hightide-8.1.0/jetty-hightide-8.1.0.RC2.zip

2.新建jetty-dataSource.xml文件,放在${JETTY_HOME}\contexts目录下

这个例子新建了两个mysql数据源,

/datasource

./

jdbc/showcase

com.mysql.jdbc.Driver

jdbc:mysql://localhost:3306/showcase?useUnicode=true&characterEncoding=UTF8

root

111111

jdbc/quartz

com.mysql.jdbc.Driver

jdbc:mysql://localhost:3306/quartz?useUnicode=true&characterEncoding=UTF8

root

111111

3.将数据源用到的jar包放到${JETTY_HOME}\lib\ext目录下

因为以上用到了c3p0数据库连接池和mysql数据库,因此需要将mysql-connector-java-5.1.17.jar和c3p0-0.9.1.2.jar放到jetty容器的lib中

4.重启jetty容器

命令行到${JETTY_HOME}目录下,运行 java -jar start.jar启动容器

5.附:常见的jndi数据库链接池配置

Pooling DataSources

Enables connection pooling. Connection pooling lets you reuse an existing connection instead of creating a new connection to the database.This is highly efficient in terms of memory allocation and speed of the request to the database. We highly recommend this option for production environments.

BoneCP

jdbc/DSTest

com.mysql.jdbc.Driver

jdbc.url

jdbc.user

jdbc.pass

5

50

5

30

c3p0

jdbc/DSTest

org.some.Driver

jdbc.url

jdbc.user

jdbc.pass

dbcp

jdbc/DSTest

org.some.Driver

jdbc.url

jdbc.user

jdbc.pass

SELECT 1

Note: validationQuery is optional, and works together with the testOnBorrow parameter (which defaults to true but has no effect unless validationQuery is specified) to help ensure that old connections are valid when used. See http://commons.apache.org/dbcp/configuration.html

Atomikos 3.3.2+

Connection pooling + XA transactions.

jdbc/DSTest

2

50

com.mysql.jdbc.jdbc2.optional.MysqlXADataSource

DSTest

url

jdbc:mysql://localhost:3306/databasename

user

some_username

password

some_password

Non-pooling DataSources

If you are deploying in a production environment, use the Pooling DataSources instead.

MySQL

Implements javax.sql.DataSource, javax.sql.ConnectionPoolDataSource

jdbc/DSTest

jdbc:mysql://localhost:3306/databasename

user

pass

SQL Server 2000

Implements javax.sql.DataSource, javax.sql.ConnectionPoolDataSource

jdbc/DSTest

user

pass

dbname

localhost

1433

Oracle 9i/10g

Implements javax.sql.DataSource, javax.sql.ConnectionPoolDataSource

jdbc/DSTest

thin

jdbc:oracle:thin:@fmsswdb1:10017:otcd

xxxx

xxxx

true

MinLimit

5

PostgreSQL

Implements javax.sql.DataSource

jdbc/DSTest

user

pass

dbname

localhost

5432

Implements javax.sql.ConnectionPoolDataSource

jdbc/DSTest

user

pass

dbname

localhost

5432

Sybase

Implements javax.sql.DataSource

jdbc/DSTest

dbname

user

pass

servername

5000

DB2

Implements javax.sql.DataSource

jdbc/DSTest

dbname

user

pass

servername

50000

Implements javax.sql.ConnectionPoolDataSource

jdbc/DSTest

dbname

user

pass

servername

50000

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值