在webapp中运行时,Derby无法创建数据库?

时间:2015-09-14 12:49:20

标签: tomcat7 derby javadb

我在Web应用程序(tomcat7)中有这个代码:

public InitBean() throws UnknownHostException, Exception {
    NetworkServerControl server = new NetworkServerControl(
            InetAddress.getByName("localhost"), 1527);
    server.start(new PrintWriter(System.err));

    String driver = "org.apache.derby.jdbc.ClientDriver";
    Class.forName(driver).newInstance();
    Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/ctc;create=true");

}

目的是创建一个可以从webapp内部和外部访问的Derby数据库。这是一个涉及数据库ETL工具的不常见的用例。

我收到此错误:

Sep 14, 2015 7:23:19 AM org.apache.catalina.core.StandardContext loadOnStartup
SEVERE: Servlet /map threw load() exception
ERROR XJ041: DERBY SQL error: ERRORCODE: 40000, SQLSTATE: XJ041, SQLERRMC: Failed to create database 'ctc', see the next exception for details.::SQLSTATE: XBM02
    at org.apache.derby.client.am.ClientConnection.completeSqlca(Unknown Source)
    at org.apache.derby.client.net.NetConnectionReply.parseRdbAccessFailed(Unknown Source)
    at org.apache.derby.client.net.NetConnectionReply.parseAccessRdbError(Unknown Source)
    at org.apache.derby.client.net.NetConnectionReply.parseACCRDBreply(Unknown Source)
    at org.apache.derby.client.net.NetConnectionReply.readAccessDatabase(Unknown Source)
    at org.apache.derby.client.net.NetConnection.readSecurityCheckAndAccessRdb(Unknown Source)
    at org.apache.derby.client.net.NetConnection.flowSecurityCheckAndAccessRdb(Unknown Source)
    at org.apache.derby.client.net.NetConnection.flowUSRIDONLconnect(Unknown Source)
    at org.apache.derby.client.net.NetConnection.flowConnect(Unknown Source)
    at org.apache.derby.client.net.NetConnection.<init>(Unknown Source)
    at org.apache.derby.client.net.ClientJDBCObjectFactoryImpl.newNetConnection(Unknown Source)
    at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)
    at java.sql.DriverManager.getConnection(DriverManager.java:664)
    at java.sql.DriverManager.getConnection(DriverManager.java:270)
    at com.ctc.service.InitBean.<init>(InitBean.java:40)

这是在Windows 7,64位,Java 8和Tomcat 7上。

可能是什么问题?

更新

完全相同的代码在独立应用程序(J2SE / JUnit)中工作正常,但在Tomcat / Springframework下失败。

0 个答案:

没有答案