Skip to content

Commit 9a54625

Browse files
committed
Only shutdowns a single DB rather than the whole Derby driver
1 parent d4cedc5 commit 9a54625

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

core/src/test/java/org/apache/spark/JavaJdbcRDDSuite.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public void setUp() throws ClassNotFoundException, SQLException {
4343

4444
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
4545
Connection connection =
46-
DriverManager.getConnection("jdbc:derby:target/JdbcRDDSuiteDb;create=true");
46+
DriverManager.getConnection("jdbc:derby:target/JavaJdbcRDDSuiteDb;create=true");
4747

4848
try {
4949
Statement create = connection.createStatement();
@@ -72,9 +72,11 @@ public void setUp() throws ClassNotFoundException, SQLException {
7272
@After
7373
public void tearDown() throws SQLException {
7474
try {
75-
DriverManager.getConnection("jdbc:derby:;shutdown=true");
75+
DriverManager.getConnection("jdbc:derby:target/JavaJdbcRDDSuiteDb;shutdown=true");
7676
} catch(SQLException e) {
77-
if (e.getSQLState().compareTo("XJ015") != 0) {
77+
// Throw if not normal single database shutdown
78+
// https://db.apache.org/derby/docs/10.2/ref/rrefexcept71493.html
79+
if (e.getSQLState().compareTo("08006") != 0) {
7880
throw e;
7981
}
8082
}
@@ -90,7 +92,7 @@ public void testJavaJdbcRDD() throws Exception {
9092
new JdbcRDD.ConnectionFactory() {
9193
@Override
9294
public Connection getConnection() throws SQLException {
93-
return DriverManager.getConnection("jdbc:derby:target/JdbcRDDSuiteDb");
95+
return DriverManager.getConnection("jdbc:derby:target/JavaJdbcRDDSuiteDb");
9496
}
9597
},
9698
"SELECT DATA FROM FOO WHERE ? <= ID AND ID <= ?",

core/src/test/scala/org/apache/spark/rdd/JdbcRDDSuite.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,11 @@ class JdbcRDDSuite extends FunSuite with BeforeAndAfter with LocalSparkContext {
6565

6666
after {
6767
try {
68-
DriverManager.getConnection("jdbc:derby:;shutdown=true")
68+
DriverManager.getConnection("jdbc:derby:target/JdbcRDDSuiteDb;shutdown=true")
6969
} catch {
70-
case se: SQLException if se.getSQLState == "XJ015" =>
71-
// normal shutdown
70+
case se: SQLException if se.getSQLState == "08006" =>
71+
// Normal single database shutdown
72+
// https://db.apache.org/derby/docs/10.2/ref/rrefexcept71493.html
7273
}
7374
}
7475
}

0 commit comments

Comments
 (0)