Search code examples
javadatabaseconnectionstardog

Stardog DB connection with Java


I'm trying to do something really simple: will connect to the DB, read some records, and display them in a nice interface.

So far all I've done is start and stop the server, using the following code:

Server aServer = Stardog
                .buildServer()
                .bind(SNARLProtocolConstants.EMBEDDED_ADDRESS)
                .start();

To operate this, I had to download and import SLF4J, and also import all libraries found in my stardog / server.

Then I could start and stop the server, but my problem is I can not connect to my database.

I am using the following code to try to connect:

try (Connection aConn = ConnectionConfiguration
                .to("myDB")
                .credentials("admin", "admin")
                .connect())
        {
            aConn.begin();
            ...
            ...
        }

I affirm that I am sure that my credential data and database name are correct.

That try, going straight finally, catch bypasses.

In addition I can say, I was leading me by the link below. I'm coding in Eclipse 4.5.2, and using Java 1.8.

What am I doing wrong?. Thank you.


Solution

  • If the only jars you've included in the classpath are what's in stardog / server, then the likely cause is that you're missing some required dependencies.

    Probably, either the contents of client/http and/or client/snarl.

    But really, you shouldn't be managing that manually, use Gradle or Maven.