MongoDB Connection Issue over SSL - mongodb

I am Not able to connect mongoDB which is over the SSL. Without SSL its working fine.
I tried to ping from datasource connection setting, but its failing. Additionally I have imported public certificate to my jvm keystore.
mongodb connection url that I'm trying with is,
mongodb://[user]:[password]#[hostname]:[port]/[database]?ssl=true

Here, the issue is with ODA driver, which wasn't supporting the SSL based mongo.
Solution is to add mongo-java driver version 2.13.1 to BirtRuntime and delete existing ODA driver org.eclipse.orbit.mongodb_2.10.1.v20130422-1135.jar.
Once done, connect to mongo using connection url, mongodb://[user]:[password]#[hostname]:[port]/[database]?ssl=true

Related

Spring application issues to connect to mongo db

Spring boot application.
MongoDb Database hosted on mongodb cloud.
Application propperties
#Database connection string
spring.data.mongodb.host=cluster0.mbdhj.mongodb.net
spring.data.mongodb.port=27017
spring.data.mongodb.database=sample_supplies
spring.data.mongodb.username=user
spring.data.mongodb.password=[my password]
spring.data.mongodb.auto-index-creation=true
Error
com.mongodb.MongoSocketException: No such host is known (cluster0.mbdhj.mongodb.net)
If I use the same host/port/user/password combination with MongoDb Compass, i can connect without issues.
If I use a cluster connection like this
spring.data.mongodb.host=cluster0-shard-00-02.mbdhj.mongodb.net
the application throws error
com.mongodb.MongoSocketReadException: Prematurely reached end of stream
I've opened the firewall, to accept any connection.
Analitics show some actions, but i still get error in Spring.
I was just following a single youtube tutorial. In their example this didn't cause any issue.
What am I doing wrong?
Should I write a class that connects via Java to the database?
Mongo cloud instances do not allow direct connection while debugging

ODBC connection from Postgres database into Power bi error

Hi I am having issues connecting to my postgres database, I am using this connection string on my 64 bit machine. I have downloaded the updated 64 bit postgres driver.
driver used: database=Travel_Information;driver={PostgreSQL Unicode(x64)};port=5432;server=travel-information.chda0n3dhd8k.eu-west-1.rds.amazonaws.com
Issue when selecting tables to import
Any suggestions?
In the DSN select "(None)" instead of "dBASE Files" and your connection string should look like this.
database=dbname;driver={PostgreSQL Unicode(x64)};port=5432;server=server.eu-w1.compute.server.com;sslmode=require;
I had to use sslmode=require because I am connecting to a postgresql server instance on heroku server, and it requires it.
It is an SSL issue
I added sslmode=require at the end of connection string and it succeeded.
I tried before with the original Postgredb connector and various Npgsql versions but it didn't worked.
Although there's still an option to import the certificate from the server to your client To get the SSL cert for the PostgreSQL server you might need to speak to the DBA/sysadmin if you don’t have access. In the configuration folder for the PostgreSQL server there is a postgresql.conf file, search it for ssl settings, there is one with the location of the ssl cert. Note NOT the key file which contains the private key, only the cert file which contains the public key. copy it or its content to the machine running PowerBI and import using that procedure

Is there any mongodb client that accepts SSL

I am using Robomongo but I am unable to connect to my mongodb since it is ssl enabled. So, I am currently connecting through cmd, but it has its limitations like page buffer and I am missing the UI experience.
RoboMongo version 10 has support for SSL, use this version.
More info - http://blog.robomongo.org/robomongo-rc10/

Error : No unix socket support on windows connecting mongodb

I'm using robomongo tool to access mongodb. When I connect into my db then
Show error details
How to fix it?
I had the same issue and was able to fix it by removing the full url (for example: mongodb://myuser:mypassword#mongodb-test.mydomain.com/my_database) in the connection tab and only putting in the mongodb server url: mongodb-test.mydomain.com.
Next, in the Authentication tab, I checked the Perform authentication checkbox, specified the Database, user name, password.
I also added the database in the Advanded tab just in case and I can now connect without error.
Try inserting only e.g: ds12345.mlab.com at address bar instead of full [http:// mongodb://<dbuser>:<dbpassword>#...] and create user to authenticate in mlab.com and then try connect to it. Something like this:
And then:
Whilst this answer is only partly related to the problem, I want to describe the solution in here.
I had this problem when trying to connect via Robo3T to a cluster of MongoDBs hosted on Atlas. They offer a connection string with the protocol in front (e.g. mongodb+srv://<USER>:<PASSWORD>#database-mongodb.net/admin). This was a combination of two problems:
Robo3T does not like the protocol mongodb+srv:// in the URI. You should use only the second part (after the #). Like: database-mongodb.net.
Robo3T does not like shards. At least I could not get to connect with it via that connection string. Fro what I understand, you need that protocol to connect to a shard. Since you can't use that kind of URI, you will need to connect directly to the primary shard. To do that, you need to build a new connection string with the URI of the primary shard. Like this: database-shard-00-00-vemhh.mongodb.net and provide the port to Robo3T. Also, you need to connect via SSL, if you're using MongoDB Atlas (a self-signed certificate configured directly in Robo3T worked for me).
Remove only [http://] worked for me
Get the newer version of the Robo3T client...it can import it automatically from +srv link
I was facing the same problem, but I can solve it by installing Robo 3T 1.3 and import connection details from MongoDB SRV connection string. See this:
Steps to connect remote DB from Robo 3T 1.3
Remember to replace the user in the connection string and the pass at Authentication Tab
The connection string in the picture is dummy by the way

c3p0 pool cannot establish a connection. How to debug this?

I have a Tomcat and PostgreSQL installed on a server. I'm having a connection problem trying to connect from my servlet to PostgreSQL database using c3p0 pool.
I can reach DB if I'm running Tomcat locally on my laptop. Also I can connect from server to DB using psql (i.e. command line sql utility). But when I'm trying to deploy my servlet to server and establish a connection I'm getting the following error:
java.sql.SQLException: Connections could not be acquired from the underlying database!
com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
...
com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
What should I check to locate a problem? It should be a trivial issue but may be due to 4 a.m. I'm missing something :) Thanks in advance!
PS: Connection from all network interfaces are allowed to database. PostgreSQL JDBC driver and c3p0 pool are distributed in WAR. Tomcat configuration is very default. JNDI is not used.
You need to check a few things:
java.policy which tomcat is using
(e.g.
/etc/tomcat5.5/policy.d/02debian.policy)
db server settings (e.g.
/etc/postgresql/pg_hba.conf)
try connecting without pool first as
in my case c3p0 was hiding important information from me
Adding to #Alexey's answer, I had this issue with Tomcat and PostgreSQL 9.4. In my case, the md5 authentication method in postgres was causing the issue.
If you are using Windows server or RHEL server, make sure you update the authentication method in pg_hba.conf file. Modify it to trust and restart postgresql.