crate-jdbc
crate-jdbc copied to clipboard
Add dependencies to top-level project
trafficstars
Summary of the changes / Why this is an improvement
I am building the driver from current HEAD of master with the command:
./gradlew publishJdbcStandalonePublicationToMavenLocal
All tests pass when running the command
CRATE_URL=https://cdn2.crate.io/downloads/releases/cratedb/x64_mac/crate-5.9.0.tar.gz ./gradlew test
In a simple application, I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: io/crate/shade/com/fasterxml/jackson/core/JsonProcessingException
The simple application's build.gradle is:
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
mavenLocal()
}
dependencies {
// Use JUnit Jupiter for testing.
testImplementation libs.junit.jupiter
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
// This dependency is used by the application.
implementation libs.guava
implementation files('../../../Projects/crate-jdbc/build/libs/crate-jdbc-standalone-2.7.0-f2f040a.jar')
}
// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(11)
}
}
application {
// Define the main class for the application.
mainClass = 'cratejdbcexperiments.App'
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
and the application is:
package cratejdbcexperiments;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;
public class App {
public static void main(String[] args) {
Properties connectionProps = new Properties();
connectionProps.put("user", "crate");
connectionProps.put("tcpKeepAlive", true);
try {
System.out.println("Initializing");
Connection conn = DriverManager.getConnection("jdbc:crate://localhost:5432/", connectionProps);
PreparedStatement stmt = conn.prepareStatement("SELECT * FROM iris");
System.out.println("Query");
ResultSet results = stmt.executeQuery();
long size = 0;
while (results.next()) {
size++;
}
System.out.println("Length: " + size);
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
System.out.println("Done");
}
}
By adding the dependencies to the top-level build.gradle, the app is able to run.
Checklist
- [ ] ~Link to issue this PR refers to (if applicable): Fixes #???~