benk3r / EGR198-TaskApp

2 stars 0 forks source link

Connect to Database w/ Java #20

Open BeccaHurtado opened 1 year ago

BeccaHurtado commented 1 year ago

Reach a connection to Mongodb database through Java.

BeccaHurtado commented 1 year ago

@benk3r Steps followed through Mongodb : https://www.mongodb.com/docs/drivers/java/sync/current/quick-start/

We have `

org.mongodb
        <artifactId>mongodb-driver-sync</artifactId>
        <version>4.11.0</version>
    </dependency>` as a dependency in pom.xml

Error we are receiving when trying to run code. becca@Rebeccas-MacBook-Air tasktracker % cd /Users/becca/Documents/EGR198-TaskApp/tasktracker ; /usr/bin/env /Users/becca/.vsco de/extensions/redhat.java-1.23.0-darwin-x64/jre/17.0.8.1-macosx-x86_64/bin/java @/var/folders/jt/r75kp9ns4x3czq_9mt4bmgg00000gn/ T/cp_9qvq3zvirz7zgqq2sgr2zkwtn.argfile egr198.example.tasktracker.App Exception in thread "main" java.lang.NoClassDefFoundError: com/mongodb/internal/connection/StreamFactoryHelper at com.mongodb.client.internal.MongoClientImpl.getStreamFactory(MongoClientImpl.java:235) at com.mongodb.client.internal.MongoClientImpl.createCluster(MongoClientImpl.java:227) at com.mongodb.client.internal.MongoClientImpl.<init>(MongoClientImpl.java:73) at com.mongodb.client.MongoClients.create(MongoClients.java:108) at com.mongodb.client.MongoClients.create(MongoClients.java:50) at egr198.example.tasktracker.App.main(App.java:28) Caused by: java.lang.ClassNotFoundException: com.mongodb.internal.connection.StreamFactoryHelper at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) ... 6 more

We are not sure why an error is given in the terminal once we try to run the Java file. Could you take a look at our files and provide feedback?

benk3r commented 1 year ago

I'll take a look at today's session

benk3r commented 1 year ago

@BeccaHurtado Here's one of the guides for Maven I recommended earlier: https://www.baeldung.com/install-maven-on-windows-linux-mac