I have created a web application in Java and hosted it on a VM. It is getting hosted as I can see the start page of web application. But the problem arises when the hosted web application tries to connect to the Postgres database.
This web application is properly getting connected on the local host if I use the following connection string for JDBC:
DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres",
"postgres", "password");
But when hosted on VM it is not getting connected. I tried everything from other stackoverflow thread like this to change the configuration files of Postgres in VM but still it is not working.
Note: Postgres is also running on VM.
I have converted my web application from local host to .war file and deployed this file on the VM.
Can anyone tell if I have to do any other additional settings in order for the hosted web application to query the database in the VM?
Resolved this issue. The problem was that I didn't include some of the jar files that I was using in the web application in Apache Tomcat lib folder.
Do you also run Postgres on VM ? If not you can not connect it through localhost since the localhost for your web app is VM's address. If so check the firewall and allow the 5432 port to be able to connect.
Related
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?
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
I have deployed my java web application using apache tomcact in my system through Eclipse. I can access the same page with
https://localhost:8080/Home.jsp
as well
https://mysystemip:8080/Home.jsp
But the same page is not able to connect
https://mysystemip:8080/Home.jsp over the network through other systems. Previously it was working and now not. What issue causing this ?
Your Tomcat server is only bound to your local network interface. You need to bind it to all interfaces for it to be available.
There is already a solution (Can't access Tomcat using IP address):
Add address="0.0.0.0" to Connector string
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:)
With Basic4Android I can get access to a SQL server database using Remote Database Connector (RDC) (see http://www.b4x.com/android/forum/threads/remote-database-connector-rdc-connect-to-any-remote-db.31540/ ).
I can put the SQL server database on Azure.
But how can I put the Java web server on Azure ?
Per my experience, I suggest you to create a Windows VM on Azure and install Java Environment to deploy the RDC on it. Please refer to https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-windows-tutorial-classic-portal/ and https://azure.microsoft.com/en-us/documentation/articles/virtual-machines-log-on-windows-server/.
Why is Azure VM? Why is Windows?
The causes are as following:
The RDC is a lightweight Java web server based on Jetty, and the Jetty version is 7.4.2. However, the version of Jetty on Azure Webapps from gallery is 9.1.2. They have the incompatible component of different implementation, such as Websocket.
The Jetty Server of RDC is running as a standalone application, not a Java servlet container. So RDC can not be deployed on Azure Webapps.
The RDC http listen port is 17178. It can be configured in config.properties. But if RDC as a CloudService run on Azure, you need to configure some properties for Cloud Service Role such as public ip & port.
If you want to deploy it on Azure Linux VM, you need to run command chmod u+x for the decompressed files in RDC.zip and create a RunRLC.sh for boot Main class 'RemoteServer'.
Note: I recommend Microsoft SQL JDBC version 4.0+ Driver to access Azure SQLDatabase and SQL Server on Azure. The RDC's default JDBC for MSSQL is jTDS that it is incompatible with MSSQL on Azure.
Best Regards.