Remote MongoDB successful only when MongoDB is open on local - java

I have a Ubuntu VM in an EC2 AWS instance, with MongoDB installed. I can successfully save information to this database on my local machine using a spring boot application. However, this remote connection can only be made when I have a connection to remote Mongodb open on my local machine. Otherwise, the connection is refused.
My end goal is to have a mobile application that can preform CURD operations to a remote MongoDB.
Any help regarding this issue is appreciated.
Thanks.

You shouldn't be trying to connect to a remote MongoDB from a mobile application because anyone will be able to tamper with the information you are storing in it.
Consider using a local database bundled along with your mobile application or connecting from your mobile application to your Spring boot app which can then talk to the MongoDB instance.

Please check some point.
1: Please check remote connection open in your Mongo instance
2: Ec2 Instance have public accessibility
3: Ec2 Instance mongo port enabled and remotely accessible.
Did you confirm that the bind_ip actually changed to 0.0.0.0/0, ::/0

Related

How to connect MsAccess database existing in windows folder using Kubernetes

I have an MSAccess database in my local windows. and I need to connect it with java code using Kubernetes.
I tried to use the below:
jdbc:ucanaccess:///run/desktop/mnt/host/c/Users/Public/fdb/F_B_1_2.mdb;jackcessOpener=com.sms-manager.mobile_app.mobileapp.manage.CryptCodecOpener
But it's not working with me.
it's giving java error database not existing.
Is your java application running in container and trying to connect to ms access db which is in another machine? if yes then you can create Kubernetes service and endpoint of your db server or external name of db server. Choose suitable JDBC and ODBC driver to connect to MS Access Database

Connect to RDS AWS db using SSH key from java

I have a java application that is deployed on AWS EC2 instance. This application is connecting to an AWS RDS db. This works fine. But from my local windows when I debug the code in intellij, it is not able to connect to db because it require an ssh key and EC2 instance ip for connection along with password.
Java application uses oracle hibernate connection with entity manager.
I came across this solution
https://www.jetbrains.com/help/idea/connectivity-problems.html#step-4-check-if-the-connection-with-ssh-ssl
but I don't see SSH configuration option on Tool windows in my Intellij.
Could someone help me on how can I make db connection using java application using intellij or by deploying application in tomcat in my local?

Can't connect to a database on Amazon RDS from Amazon EC2 ubuntu 16.04 image

I have hosted a play framework web application on Amazon EC2 instance. The application is not able to connect to a mysql database located on the Amazon RDS instance. When I run the play framework web application on my local computer it successfully connects to the database on the Amazon RDS instance. I checked the database connection credentials in the production conf file many times. Looks correct.
When I do
mysql -h********.rds.amazonaws.com -p****** -u****** db_name
from the local computer it quickly connects. But when I try same connection to RDS from EC2 it throws:
ERROR 2003 (HY000): Can't connect to MySQL server on ********.rds.amazonaws.com
Can anyone kindly help me with this or suggest anything that I may be possibly missing.
Is RDS in VPC?
Yes, Check if EC2 is also in VPC or not.
No, Check security group that EC2 is in, allows the communication over database port
For more info and scenarios, head here

Connection to Openshift Online 3 from JAVA code outside the cloud

Openshift 2 will not work from tomorrow. Online 3 version is available. I use starter type.For Openshift 2 I could write/read data to/from MySQL DB located on openshift from my application that located on my PC, I mean from the code outside of the cloud. But now, with version 3 I have no idea hot to do it.
How to it now?
Is it possible to connect my local MySQL WorkBench to MySQL DB on Openshift Online 3 as well?
Port forwarding is very common method to make secure connection to remote machines. Its like creating a secure connection from your machine to the host machine. Once connection is build, any tool like MYSQL workbench can connect via localhost:<localport> where would forward the connection to remote machine's port.
Please read more about this feature here.
The port forwarding can be setup via any shell client supporting the feature, e.g. in a putty configuration.
Openshift V3 also support port forwarding through its client tool oc
Step wise:
1) Download and install oc tool. Refer here.
2) Once install on your machine (windows/linux), you could use port forwarding feature to access it from local machine.
Please refer openshift document here to setup port forward.
Once port forward is setup, leave the console open on local and try connecting to localhost:<localport> and you should actually get connected to MYSQL on openshift.
Yes, you can do this with port-forwarding:
https://katacoda.com/graham.dumpleton/courses/intro-openshift/port-forwarding

Can't connect to an AWS MySQL RDS using JDBC when site is deployed to elastic beanstalk

So I created a MySQL DB on amazon running on the same account as my tomcat server, it built and is running correctly but can't connect to the database.
I can access the remote database running the site using tomcat on my computer, and I can access the db through MySQL workbench, but when I deploy and run it I get a 500 whenever the site tries to access the database.
I opened up my security on this database to accept any connection and port(lol), and I checked if the mysql java connector.jar in the WEB-INF/libs file is the latest version. I even tried setting the JDBC connection string to localhost to see if it would pick it up, but no luck.
I think I'm missing something, can anyone think of any reason my website's JDBC can access the remote database server from my machine but not from the amazon tomcat server?
Also, this is a student project I'm building.
Hope this description makes sense, maybe someone can think of something I haven't tried:)

Categories