【发布时间】:2015-10-14 15:38:00
【问题描述】:
尝试在 JUNITTEST 的内存数据库中使用 derby 时出现以下异常。
java.sql.SQLNonTransientConnectionException:数据库“内存:testDB” 掉了。在 org.apache.derby.iapi.error.StandardException.newException(未知 来源)
@Before
public void setUp() throws Exception {
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
String connectionURL = "jdbc:derby:memory:testDB;create=true";
Class.forName(driver);
Connection conn = DriverManager.getConnection(connectionURL);
super.setUp();
}
@After
public void tearDown() throws Exception {
String connectionURL = "jdbc:derby:memory:testDB;drop=true";
DriverManager.getConnection(connectionURL);
}
【问题讨论】:
-
我假设异常发生在您的 tearDown() 方法中? “drop=true”抛出“Database dropped”异常是正常的。这就是你的问题吗?