I have two instances of my project running on Google's cloud, Tomcat Instance & Lamp Instance.
My servlets are running on tomcat instance and have to connect to the database of lamp instance.
I gave the following details of connection
String DriverName="com.mysql.jdbc.Driver";
String userName="root";
String password="root";
String driverManager="jdbc:mysql://localhost:3306/databasename";
The localhost request is going to mysql of tomcat instance(Here tomcat instance contains mysql also).It is not going to the lamp instance
So I want a way to send request to another instance.
if I placed lamp instance url means i am receiving the following exception in the logcat.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
So can anyone tell how to solve this problem
thanks in advance.
You need to enable the
Connector/J
by setting it to true, and also use thegoogle
mysql
driver instead of the genericcom.mysql.jdbc.Driver
class.Enable connector/j
Google Driver class
Code samples taken from URL.