[英]Connect JSP With MySql Database in Openshift
I am new to openshift ,I have created some static web applications using openshift. 我是openshift的新手 ,我已经使用openshift创建了一些静态Web应用程序。
now I am creating java web application in openshift using the Eclipse IDE , I need to connect mySql database created in the openshift project in my account. 现在,我正在使用Eclipse IDE在openshift中创建Java Web应用程序 ,我需要在我的帐户中连接在openshift项目中创建的mySql数据库 。 when I trying to connect I am getting an exception
当我尝试连接时出现异常
Communications link failure The last packet sent successfully to the server was 0 milliseconds ago.
通信链接失败最近一次成功发送到服务器的数据包是在0毫秒之前。 The driver has not received any packets from the server.
驱动程序尚未收到来自服务器的任何数据包。
please look at my code. 请看我的代码。
JSP 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>
I have added mysql driver to my project, the url marked as * is as exact ip seen in phpmyadmin server url, and user name and password are also correct. 我已将mysql驱动程序添加到我的项目中,标记为*的URL与phpmyadmin服务器URL中所见的IP完全相同,并且用户名和密码也正确。
if anyone knows the problem,please help me. 如果有人知道问题,请帮助我。
Add mysql driver to the Deployment Assembly . 将mysql驱动程序添加到Deployment Assembly中 。
you can done it by : Project properties -> Deployment Assembly -> Add -> Archives from file system. 您可以通过以下方式完成此操作:项目属性->部署程序集->添加->文件系统中的存档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.