java how to connect to a MySQL database in OpenShift -
package library; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; import java.util.logging.level; import java.util.logging.logger; public class conexion { private string server = "jdbc:mysql://" + system.getenv("openshift_mysql_db_host") + ":" + system.getenv("openshift_mysql_db_port") + "/" + system.getenv("openshift_app_name") + ""; private string user = system.getenv("openshift_mysql_db_username"); private string pass = system.getenv("openshift_mysql_db_password"); private connection conn; public connection conectar() throws classnotfoundexception, sqlexception { try { class.forname("com.mysql.jdbc.driver"); this.conn = drivermanager.getconnection(server, user, pass); } catch (exception ex) { logger.getlogger(conexion.class.getname()).log(level.severe, null, ex + ex.getmessage()); } return this.conn; } }
i have java application lodged in openshift when try connect cartridge mysql nothing happens when connect. stays in servlet , takes no other action
depending on type of java server running on openshift, try reading through 1 of these articles, should database connection , running:
Comments
Post a Comment