jboss配置 mysql数据库连接池实例 1 :配置: JDK 1.5 JBoss4.0.4 Mysql5.0 Myeclipse 4.1 2: 建立数据库: create database test; use test; DROP TABLE IF EXISTS `test`; CREATE TABLE `test` ( `Test_id` int(11) NOT NULL auto_increment, `Test_name` varchar(45) NOT NULL default '', `Test_password` varchar(45) NOT NULL default '', PRIMARY KEY (`Test_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `test` VALUES (1,'test','test'),(2,'test2','test'); 3:Copy MySQL的JDBC驱动放到jboss-4.0.4serverdefaultlib 可到MYsql网站下载 4:在 jboss-4.0.4serverdefaultdeploy下新建文件mysql-ds.xml 可从jboss-4.0.4docsexamplesjca copy 修改 想配置多个连接池只要多加一个 其中内容如下:
<!-- $Id: mysql-ds.xml,v 1.3.2.3 2006/02/07 14:23:00 acoliver Exp $ --> <!-- Datasource config for MySQL using 3.0.9 available from: http:///downloads/api-jdbc-stable.html --> test jdbc:mysql://127.0.0.1:3306/test com.mysql.jdbc.Driver rootxxxxxxxx org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter <!-- should only be used on drivers after 3.22.1 with "ping" support org.jboss.resource.adapter.jdbc.vendor.MySQLValidConnectionChecker --> <!-- sql to call when connection is created some arbitrary sql --> <!-- sql to call on an existing pooled connection when it is obtained from pool - MySQLValidConnectionChecker is preferred for newer drivers some arbitrary sql -->
<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) --> mySQL
5:修改jboss-4.0.4serverdefaultconf standardjaws.xml java:/test mySql .....
修改jboss-4.0.4serverdefaultconf standardjbosscmp-jdbc.xml java:/test mySql