Hello everyone,
I’m currently facing an issue when trying to connect to my MongoDB instance from the Knowage application using a JDBC connection. The connection string I’m using is:
mongodb://localhost:27017/db_name
However, I’m encountering the following error:
Caused by: com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=mongodb://localhost:27017:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketException: mongodb://localhost:27017}, caused by {java.net.UnknownHostException: mongodb://localhost:27017}}]
It seems like the connection is timing out, and the MongoDB server is not being recognized correctly.
Has anyone experienced a similar issue? Any suggestions on how to resolve this problem or things I should check to ensure a proper connection?
Thanks in advance for any help!
Regards
Darshan Hiranandani
1 Like
Hello @Darshan_Hiranandani
I think the first thing to know is whether you are using our newer Atlas SQL JDBC Driver or the older one, that is associated with our BI Connector.
If your db is in Atlas, I highly suggest you use our Atlas SQL JDBC Driver.
Also, from reading the Knowage docs, it appears they have established a way to connect to MongoDB using a Java driver. Add new Data Source — Knowage documentation
But, possibly our new SQL JDBC Driver could work, it is hard to tell until I get in there first hand.
Here are the instructions Knowage published for a Java connection (Not JDBC):
Example parameters for the connection are:
** Dialect: MongoDB;*
** Driver Class: mongo;*
** Connection URL: mongodb://localhost:27017/foodmart(please don’t include user and password in this URL).*
Please keep in mind that the user needs the correct privileges to access to the specified database. For example, on MongoDB you can create a user using this command on the Mongo shell.
This last tip is important, basically it says that you can test out connection and user priveledges from a connection within our Mongosh (Mongo Shell).
Connection may be timing out if you are mixing the JDBC Driver with the Java Driver? I am interested proving out connection to this tooling, so please keep me posted.
Best,
Alexi
PM SQL Interface, BI Connector