首页 > 有人在BAE开发过java-tomcat应用吗?数据库老是链接失败

有人在BAE开发过java-tomcat应用吗?数据库老是链接失败

我的jsp代码如下

<%@ page contentType="text/html;charset=utf-8"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%
Connection con;
Statement sql;
ResultSet rs;
try{Class.forName("com.mysql.jdbc.Driver").newInstance();}
catch(Exception e){out.print(e);}
try{
    String url="jdbc:mysql://sqld.duapp.com:4050/***";
    con=DriverManager.getConnection(url,"***","***");
    out.print(con);
    con.close();
}
catch(SQLException e1){out.print(e1);}
%>
</body>
</html>

访问的结果如下

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver

java.sql.SQLException: No suitable driver found for jdbc:mysql://sqld.duapp.com:4050/***

原因应该是没有mysql驱动,看官方文档也没有特别说明。请问问题出在哪里?


重启了执行单元好了,可是又报错

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server。

bae 数据库貌似不太稳定。


没用过BAE,但自己把mysql驱动放在WEB-INF的lib目录下不可以么


你下载那个bae上的demo下来。里面由mysql的驱动包的。我之前直接是在下载的demo里面做项目的。应该是没问题的。。

【热门文章】
【热门文章】