Skip to content

Commit

Permalink
Java JDBC: Use explicit schema name testdrive
Browse files Browse the repository at this point in the history
Otherwise, resources would be created within the `crate` schema, which
might be unfortunate when users are copying the examples. The intention
of the micro examples is to show users best practices.
  • Loading branch information
amotl committed Nov 22, 2024
1 parent 65efac9 commit b1979b1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions by-language/java-jdbc/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
test:
mvn exec:java -Dexec.args="--dburl 'jdbc:postgresql://localhost:5432/'"
mvn exec:java -Dexec.args="--dburl 'jdbc:crate://localhost:5432/'"
mvn exec:java -Dexec.args="--dburl 'jdbc:postgresql://localhost:5432/testdrive'"
mvn exec:java -Dexec.args="--dburl 'jdbc:crate://localhost:5432/testdrive'"
8 changes: 4 additions & 4 deletions by-language/java-jdbc/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@ Invoke example program::
Connect to instance on ``localhost``::

# Use vanilla PostgreSQL JDBC driver.
mvn exec:java -Dexec.args="--dburl 'jdbc:postgresql://localhost:5432/'"
mvn exec:java -Dexec.args="--dburl 'jdbc:postgresql://localhost:5432/testdrive'"

# Use CrateDB legacy JDBC driver.
mvn exec:java -Dexec.args="--dburl 'jdbc:crate://localhost:5432/'"
mvn exec:java -Dexec.args="--dburl 'jdbc:crate://localhost:5432/testdrive'"

Connect to CrateDB Cloud::

# Use vanilla PostgreSQL JDBC driver.
mvn exec:java -Dexec.args="--dburl 'jdbc:postgresql://example.aks1.westeurope.azure.cratedb.net:5432/' --user 'admin' --password '<PASSWORD>'"
mvn exec:java -Dexec.args="--dburl 'jdbc:postgresql://example.aks1.westeurope.azure.cratedb.net:5432/testdrive' --user 'admin' --password '<PASSWORD>'"

# Use CrateDB legacy JDBC driver.
mvn exec:java -Dexec.args="--dburl 'jdbc:crate://example.aks1.westeurope.azure.cratedb.net:5432/' --user 'admin' --password '<PASSWORD>'"
mvn exec:java -Dexec.args="--dburl 'jdbc:crate://example.aks1.westeurope.azure.cratedb.net:5432/testdrive' --user 'admin' --password '<PASSWORD>'"

In order to clean the build artefacts, invoke::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class JdbcMetaDataTest {
.fromURL("https://cdn.crate.io/downloads/releases/nightly/crate-latest.tar.gz")
.settings(Map.of("psql.port", 55432))
.build();
public static final String URL = "jdbc:postgresql://localhost:55432/doc?user=crate";
public static final String URL = "jdbc:postgresql://localhost:55432/testdrive?user=crate";

@Test
public void test_allProceduresAreCallable() throws Exception {
Expand Down
4 changes: 2 additions & 2 deletions by-language/java-qa/src/test/java/io/crate/qa/JdbcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public class JdbcTest {
.fromURL("https://cdn.crate.io/downloads/releases/nightly/crate-latest.tar.gz")
.settings(Map.of("psql.port", 55433))
.build();
public static final String URL = "jdbc:postgresql://localhost:55433/doc?user=crate";
public static final String URL = "jdbc:postgresql://localhost:55433/testdrive?user=crate";

@After
public void after() throws Exception {
try (var conn = DriverManager.getConnection(URL)) {
var tables = conn.getMetaData().getTables(null, "doc", null, null);
var tables = conn.getMetaData().getTables(null, "testdrive", null, null);
while (tables.next()) {
String schema = tables.getString(2);
String table = tables.getString(3);
Expand Down

0 comments on commit b1979b1

Please sign in to comment.