有时,我在使用云SQL连接时出现通信失败错误。这是错误详细信息:
{ "error": {"errors": [ {
"domain": "global", "reason": "backendError",
"message": "com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server." } ], "code": 503, "message": "com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server." }}
请帮助我。
我的java代码是:
Class.forName ("com.mysql.jdbc.GoogleDriver");
con = DriverManager.getConnection("<< connections , username,password>>");
java.sql.Statement stmt = con.createStatement();
String sqlpost = "<< here is mysql query>>";
ResultSet rst = stmt.executeQuery(sqlpost);
int count = 0;
while (rst.next()) {
Users users = new Users(rst.getInt("id"), rst.getString("altername"));
friendlist.add(users);
}
con.close ();