ハンドシェーク中に通信障害というエラーが発生しました。localhost:3306 で実行されているサーバーはありますか? タイプ 4 の jdbc ドライバーを使用して jdbc プログラムを作成しました。削除操作を実行したいのですが、IDE が Eclipse です。コード:
Class.forName("com.mysql.jdbc.Driver");
String cs="jdbc:mysql://localhost:3306/account_db";
Connection con=DriverManager.getConnection(cs,"root",<password>);
PreparedStatement ps=con.prepareStatement("delete from empde emp_id=?");
Scanner s=new Scanner(System.in);
while(true)
{
System.out.println("enter the emp_id :");
int ac_id=s.nextInt();
ps.setInt(1,emp_id);
ps.executeUpdate();
System.out.println("one emp_id is deleted:");
System.out.println("one more emp_id?(yes/no)");
String choice=s.next();
if(choice.equals("no"))
System.out.println("empde is exit");
break;
}
ps.close();
con.close();
エラーが検出されました:
java.sql.SQLException: Communication failure during handshake. Is there a server running on localhost:3306? at com.mysql.jdbc.MysqlIO.init(Unknown Source)