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.zip2.新建jetty-dataSource.xml文件,放在${JETTY_HOME}\contexts目录下这个例子新建了两个mysql数据源,/datasource./jdb
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
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)