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 <a href="https://github.com/datastax/java-driver/tree/4.x/manual/core">Manual</a>
     */
    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());
            }
        }
    }
}