Im having an app engine service connected to an Cloud SQL sec generation DB and everything is just fine, I just wanted to replace the DB structure so I've created a new DB with the new structure and moved the needed Data from the old one to the new one.
once I've deployed the service with the new DB name whenever the app engine service tries to connect to the DB the connection aborted with this error:
Aborted connection 11 to db: 'unconnected' user: 'root' host: 'localhost' (Got an error reading communication packets)
given that I'm trying to connect to the instance using JPA and the URL is like this
jdbc:mysql://google/My_DB?cloudSqlInstance=${endpoints.project.id}:${database.region}:${database.instance}&autoReconnect=true&socketFactory=com.google.cloud.sql.mysql.SocketFactory&useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL
and the user name/ password is sent over properties in the entity manager creation
find below how Im opening and closing the connection:
Im having EMF class
public final class EMF {
private static final EntityManagerFactory emfInstance =
Persistence.createEntityManagerFactory("cloud",getProp());
private EMF() {}
public static EntityManagerFactory get() {
return emfInstance;
}
private static Properties getProp() {
Properties p = new Properties();
p.put("javax.persistence.jdbc.user", Credentials.getDatabaseUsername());
p.put("javax.persistence.jdbc.password", Credentials.getDatabasePassword());
return p;
}
}
Then Im having like tens of DAO functions in all Im fowling the below steps:
public void insertSMSVerification(SMSVerification smsVerification) {
EntityManager em = null;
EntityTransaction et = null;
try {
em = EMF.get().createEntityManager();
et = em.getTransaction();
et.begin();
em.merge(smsVerification);
et.commit();
}catch (Exception e) {
if(et.isActive())
et.rollback();
DBException.handleDBException(e, LOG);
} finally {
if (em != null)
em.close();
}
}
So, any help plz?