开发者

Embedded Derby Db in a Spring app on Tomcat

开发者 https://www.devze.com 2023-01-06 08:45 出处:网络
I\'m trying to get an embedded Derby db running on a Tomcat/Spring application. <bean id=\"dataSource\" class=\"org.apache.commons.dbcp.BasicDataSource\">

I'm trying to get an embedded Derby db running on a Tomcat/Spring application.

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="org.apache.derby.jdbc.EmbeddedDriver" />
    <property name="url" value="jdbc:derby:pepper" />
    <property name="initialSize" value="5" />
    <property name="maxActive" value="50" />
</bean>

When I run this, I'm getting the following error:

org.apache.commons.dbcp.SQLNestedException: Cannot creat开发者_开发知识库e PoolableConnectionFactory (Database 'WEB-INF/pepper' not found.)

I've tried the pepper folder at both %webapp_root%/pepper and %webapp_root%/WEB-INF/pepper

Suggestions?


If you're deploying a web app to Tomcat, I'd recommend setting up a JNDI connection pool and using Spring's JndiObjectFactoryBean:

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
    <property name="jndiName" value="java:comp/env/jdbc/blah"/>
</bean>


I guess you need to replace url with jdbc:derby:pepper;create=true

0

精彩评论

暂无评论...
验证码 换一张
取 消