diff --git a/cassandra/.gitignore b/cassandra/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/cassandra/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/cassandra/pom.xml b/cassandra/pom.xml new file mode 100644 index 0000000..d1dff8a --- /dev/null +++ b/cassandra/pom.xml @@ -0,0 +1,32 @@ + + 4.0.0 + + de.hsma + cassandra + 1.0-SNAPSHOT + jar + + cassandra + + + UTF-8 + 11 + 11 + + + + + org.apache.cassandra + java-driver-core + 4.18.1 + + + + org.junit.jupiter + junit-jupiter-engine + 5.9.2 + test + + + diff --git a/cassandra/src/main/java/org/example/QueryApp.java b/cassandra/src/main/java/org/example/QueryApp.java new file mode 100644 index 0000000..fded234 --- /dev/null +++ b/cassandra/src/main/java/org/example/QueryApp.java @@ -0,0 +1,30 @@ +package org.example; + +import com.datastax.oss.driver.api.core.CqlSession; +import com.datastax.oss.driver.api.core.cql.ResultSet; +import com.datastax.oss.driver.api.core.cql.Row; + +import java.net.InetSocketAddress; + +public class QueryApp { + + /** + * + * @param args + * + * @see Manual + */ + public static void main(String[] args) { + try (CqlSession session = CqlSession.builder() + .addContactPoint(new InetSocketAddress("localhost", 9042)) // = CqlSession.builder().build() + .withLocalDatacenter("datacenter1") // benötigt wenn contact point explizit angegeben + .withKeyspace("test") // unser keyspace (z.B. use test;) + .build()) { + ResultSet rs = session.execute("select * from professoren"); + for (Row row : rs) { + System.out.println(row.getString("name")); + //System.out.println(row.getFormattedContents()); + } + } + } +} \ No newline at end of file diff --git a/mongodb/src/main/java/org/example/QueryApp.java b/mongodb/src/main/java/org/example/QueryApp.java index 249dde8..af69ba5 100644 --- a/mongodb/src/main/java/org/example/QueryApp.java +++ b/mongodb/src/main/java/org/example/QueryApp.java @@ -14,7 +14,7 @@ public class QueryApp { try (MongoClient mongoClient = MongoClients.create(uri)) { MongoDatabase database = mongoClient.getDatabase("hs"); // TODO database MongoCollection collection = database.getCollection("professoren"); // TODO collection - Document doc = collection.find(eq("Name", "Sokrates")).first(); + Document doc = collection.find(eq("Name", "Curie")).first(); if (doc != null) { System.out.println(doc.toJson()); } else {