与C3P0连接池的Tomee

时间:2014-08-12 22:29:31

标签: java c3p0 tomee

如何将C3P0连接池与Tomee一起使用?

我在tomee.xml中包含了以下配置:

<Resource id="xxxx" 
        factory-name="org.apache.naming.factory.BeanFactory"
        type="com.mchange.v2.c3p0.ComboPooledDataSource">
        JdbcDriver net.sourceforge.jtds.jdbc.Driver
        JdbcUrl jdbc:jtds:sqlserver://IP:PORT/DataBaseName;sendStringParametersAsUnicode=false;prepareSQL=3
        UserName xxxx
        Password XXXX
        JtaManaged true
        InitialSize 20 
        MaxActive 100 
        MaxIdle 30 
        MaxWait 10000
    </Resource>

但是这会抛出异常无效的类型。知道怎么设置这个吗?

1 个答案:

答案 0 :(得分:0)

你忘了写等号,你的语法无效。看看这个example on gist

您的代码应如下所示:

    <Resource id="xxxx" 
        factory-name="org.apache.naming.factory.BeanFactory"
        type="com.mchange.v2.c3p0.ComboPooledDataSource">
        JdbcDriver = net.sourceforge.jtds.jdbc.Driver
        JdbcUrl = jdbc:jtds:sqlserver://IP:PORT/DataBaseName;sendStringParametersAsUnicode=false;prepareSQL=3
        UserName = xxxx
        Password = XXXX
        JtaManaged = true
        InitialSize = 20 
        MaxActive = 100 
        MaxIdle = 30 
        MaxWait = 10000
    </Resource>