我们在jboss中配置c3 p0时遇到了问题。有两个配置文件,我们不知道我们必须更改哪一个:
Jboss浏览器app-ds.xml:
<datasources>
<datasource jta="false" jndi-name="java:/TestJNDI" pool-name="TestPool" use-ccm="false">
<connection-url>jdbc:oracle:thin:@server_test:port:database</connection-url>
<connection-property name="schema">schema</connection-property>
<driver-class>oracle.jdbc.OracleDriver</driver-class>
<driver>ojdbc6.jar</driver>
<pool>
<min-pool-size>20</min-pool-size>
<max-pool-size>400</max-pool-size>
</pool>
<security>
<user-name>user</user-name>
<password>pass</password>
</security>
<validation>
<validate-on-match>false</validate-on-match>
<background-validation>false</background-validation>
</validation>
<statement>
<share-prepared-statements>false</share-prepared-statements>
</statement>
</datasource>
</datasources>
persistence.xml:
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd" version="2.0">
<persistence-unit name="Oracle">
<description>Oracle database connection</description>
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>entity1</class>
<!-- entities -->
<class>entityN</class>
<properties>
<property name="hibernate.show_sql" value="false"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.connection.datasource" value="java:/TestJNDI"/>
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/>
<property name="hibernate.generate_statistics" value="true"/>
<!-- Important -->
<property name="hibernate.connection.provider_class" value="org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider" />
<property name="hibernate.c3p0.max_size" value="100" />
<property name="hibernate.c3p0.min_size" value="0" />
<property name="hibernate.c3p0.acquire_increment" value="1" />
<property name="hibernate.c3p0.idle_test_period" value="300" />
<property name="hibernate.c3p0.max_statements" value="0" />
<property name="hibernate.c3p0.timeout" value="100" />
</properties>
</persistence-unit>
</persistence>
日志:
INFO [org.jboss.as.jpa] (MSC service thread 1-4) JBAS011401: Read persistence.xml for Oracle
WARN [org.jboss.jaxrs] (MSC service thread 1-15) JBAS011204: resteasy.scan found and ignored in web.xml. This is not necessary, as Resteasy will use the container integration in the JAX-RS 1.1 specification in section 2.3.2
INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-15) JBAS010403: Deploying JDBC-compliant driver class oracle.jdbc.OracleDriver (version 11.2)
INFO [org.jboss.as.jpa] (MSC service thread 1-8) JBAS011402: Starting Persistence Unit Service 'AppTestEAR.ear/AppTest.war#Oracle'
INFO [org.hibernate.ejb.Ejb3Configuration] (MSC service thread 1-8) HHH000204: Processing PersistenceUnitInfo [
name: Oracle
...]
INFO [org.hibernate.service.jdbc.connections.internal.ConnectionProviderInitiator] (MSC service thread 1-8) HHH000130: Instantiating explicit connection provider: org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider
INFO [org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider] (MSC service thread 1-8) HHH010002: C3P0 using driver: oracle.jdbc.driver.OracleDriver at URL: null
INFO [org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider] (MSC service thread 1-8) HHH000046: Connection properties: {autocommit=true, release_mode=auto}
INFO [org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider] (MSC service thread 1-8) HHH000006: Autocommit mode: true
INFO [com.mchange.v2.log.MLog] (MSC service thread 1-8) MLog clients using log4j logging.
INFO [com.mchange.v2.c3p0.C3P0Registry] (MSC service thread 1-8) Initializing c3p0-0.9.1 [built 16-January-2007 14:46:42; debug? true; trace: 10]
INFO [com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource] (MSC service thread 1-8) Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@20860e3b [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@8b71134e [ acquireIncrement -> 1, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, debugUnreturnedConnectionStackTraces -> false, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, identityToken -> 2zkodt9o11wh4uo1mijhxn|327556d1, idleConnectionTestPeriod -> 300, initialPoolSize -> 3, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 180, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 200, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 20, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@d6b12b99 [ description -> null, driverClass -> null, factoryClassLocation -> null, identityToken -> 2zkodt9o11wh4uo1mijhxn|2c53cfe3, jdbcUrl -> null, properties -> {autocommit=true, release_mode=auto} ], preferredTestQuery -> null, propertyCycle -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, usesTraditionalReflectiveProxies -> false; userOverrides: {} ], dataSourceName -> null, factoryClassLocation -> null, identityToken -> 2zkodt9o11wh4uo1mijhxn|4fcb6c, numHelperThreads -> 3 ]
WARN [com.mchange.v2.async.ThreadPoolAsynchronousRunner] (Timer-3) com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1b6cdb87 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
WARN [com.mchange.v2.async.ThreadPoolAsynchronousRunner] (Timer-3) com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1b6cdb87 -- APPARENT DEADLOCK!!! Complete Status:
问题在于:
HHH010002: C3P0 using driver: oracle.jdbc.driver.OracleDriver at URL: null
我们希望在jboss(业务需求)中使用证书中提供的凭据(URL),
所以问题是:如何在jboss AS 7中配置c3 p0使用URL连接Oracle数据库?
3条答案
按热度按时间tct7dpnv1#
看起来发生的事情是,DataSource是根据
persistence.xml
中的配置和一些JDBC标准属性(例如,minPoolSize
、maxPoolSize
)被app-ds.xml
中的设置覆盖。我认为主要问题是您没有在
persistence.xml
中配置JDBC URL。(c3p0的jdbcUrl
不是JDBC标准属性,所以app-ds.xml
没有设置它。)您应该向persistence.xml
添加以下内容:user
和password
似乎也没有被设置。在persistence.xml
中添加如下内容:(To查看哪些设置已经和没有采取,滚动右查看配置信息在日志行开始
Initializing c3p0 pool...
)我试着从
app-ds.xml
中删除尽可能多的内容,这样你就不会在两个地方混淆配置。你也许能逃脱...但也许不是
fruv7luv2#
只是添加在休眠配置,你可以连接到休眠如下
eulz3vhy3#
你能碰一下hibernate.cfg.xml吗?您可以添加类似于