Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/org/duckdb/DuckDBConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public static DuckDBConnection newConnection(String url, boolean readOnly, Prope
if (db_dir.length() == 0) {
db_dir = ":memory:";
}
if (db_dir.startsWith("memory:")) {
db_dir = ":" + db_dir;
}
ByteBuffer nativeReference = DuckDBNative.duckdb_jdbc_startup(db_dir.getBytes(UTF_8), readOnly, properties);
return new DuckDBConnection(nativeReference, url, readOnly);
}
Expand Down
20 changes: 20 additions & 0 deletions src/test/java/org/duckdb/TestDuckDBJDBC.java
Original file line number Diff line number Diff line change
Expand Up @@ -3484,6 +3484,26 @@ public QueryProgress call() throws Exception {
}
}

public static void test_memory_colon() throws Exception {
try (Connection conn1 = DriverManager.getConnection("jdbc:duckdb::memory:");
Statement stmt1 = conn1.createStatement();
Connection conn2 = DriverManager.getConnection("jdbc:duckdb:memory:");
Statement stmt2 = conn2.createStatement(); Statement stmt22 = conn2.createStatement()) {
stmt1.execute("CREATE TABLE tab1(col1 int)");
assertThrows(() -> { stmt2.execute("DROP TABLE tab1"); }, SQLException.class);
stmt22.execute("CREATE TABLE tab1(col1 int)");
}
try (Connection conn1 = DriverManager.getConnection("jdbc:duckdb::memory:tag1");
Statement stmt1 = conn1.createStatement(); Statement stmt12 = conn1.createStatement();
Connection conn2 = DriverManager.getConnection("jdbc:duckdb:memory:tag1");
Statement stmt2 = conn2.createStatement()) {
stmt1.execute("CREATE TABLE tab1(col1 int)");
stmt2.execute("DROP TABLE tab1");
assertThrows(() -> { stmt1.execute("DROP TABLE tab1"); }, SQLException.class);
stmt12.execute("CREATE TABLE tab1(col1 int)");
}
}

public static void main(String[] args) throws Exception {
String arg1 = args.length > 0 ? args[0] : "";
final int statusCode;
Expand Down