【发布时间】:2015-07-02 18:05:11
【问题描述】:
我是 openshift 的新手,我使用 openshift 创建了一些静态 Web 应用程序。
现在我正在使用 Eclipse IDE 在 openshift 中创建 java web 应用程序,我需要 连接在 openshift 项目中创建的 mySql 数据库我的账户。当我尝试连接时,我得到一个exception
Communications link failure 最后一个数据包成功发送到 服务器是 0 毫秒前。驱动程序没有收到任何数据包 来自服务器。
请看我的代码。
JSP
<body>
<%
try{
Class.forName("com.mysql.jdbc.Driver");
}
catch(ClassNotFoundException e){
out.println(e.getMessage());
}
try{
Connection conn= DriverManager.getConnection("jdbc:mysql://***.*.**.*:3306/dbName","username","password");
Statement st = conn.createStatement();
out.print(st.executeUpdate("insert into user('shajeer','password')"));
out.println();
}catch(Exception e){
out.println(e.getMessage());
}
%>
</body>
我已经在我的项目中添加了mysql驱动,标记为*的url与phpmyadmin服务器url中看到的ip完全相同,用户名和密码也正确。
如果有人知道问题,请帮助我。
【问题讨论】:
标签: java mysql jsp openshift dbconnection