jndi-name指定上
Context ctx = new javax.naming.InitialContext();DataSource ds = (DataSource)ctx.lookup("java:jdbc/TestDataSource ");Connection con = ds.getConnection(); < datasources >< local-tx-datasource >< jndi-name >jdbc/TestDataSource< /jndi-name >< connection-url >jdbc:oracle:thin:@192.168.1.2:1521:test< /connection-url >< !--< connection-url >jdbc:oracle:oci:@youroracle-tns-name< /connection-url >-- >< driver-class >oracle.jdbc.driver.OracleDriver< /driver-class >< user-name >test< /user-name >< password >test< /password >< !-- Uses the pingDatabase method to check a connection is still valid before handing it out from the pool -- >< valid-connection-checker-class-name >org.jboss.resource.adapter.jdbc.vendor.OracleValidConnectionChecker< /valid-connection-checker-class-name >< !-- Checks the Oracle error codes and messages for fatal errors -- >< exception-sorter-class-name >org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter< /exception-sorter-class-name >< !-- sql to call when connection is created< new-connection-sql >some arbitrary sql< /new-connection-sql >-- >< min-pool-size >5< /min-pool-size >< !—最小连接池数目-- >< max-pool-size >800< /max-pool-size >< !—最大连接池数目-- >< idle-timeout-minutes >5< /idle-timeout-minutes >< !—数据库连接空闲时间,单位为分钟,如果负载较大,可以设为5,如果一般,可以设为3-- >< !—在从连接池里获得一个连接之前先通过执行一个简单的SQL来校验connection的有效性-- >< check-valid-connection-sql >select 1 from dual< /check-valid-connection-sql >< /local-tx-datasource >< /datasources >