AndroidアプリケーションからリモートMySQLデータベースに値を投稿しようとしています。 データベーステーブルは thisのようになります。MySQLデータベースに変数を挿入
にjava.lang.ClassNotFoundException:はcom.mysql.jdbc.Driver
エラーメッセージが言う、もし適切なドライバという、私はこのコードについては、以下のエラーメッセージを持っている
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
Connection conn = null;
try {
conn = DriverManager.getConnection("jdbc:mysql://myhost:3306/mydb",
"root", "root");
} catch (SQLException e) {
e.printStackTrace();
}
System.out.println("Connected to Database");
Statement stmt1 = null;
try {
stmt1 = conn.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
ResultSet rs1=null;
PreparedStatement sql = null;
try {
sql = conn.prepareStatement("INSERT INTO `mytable`(studentid,classid,startsig,start,end,endsig) VALUES (?, ?, ?, ?, ?, ?)");
} catch (SQLException e) {
e.printStackTrace();
}
//set values before sending
try {
sql.setString(1, studentid);
sql.setString(2, classid);
sql.setString(3, startsig);
sql.setString(4, start);
sql.setString(5, end);
sql.setString(5, endsig);
} catch (SQLException e) {
e.printStackTrace();
}
System.out.println("sql:"+sql);
try {
stmt1.executeUpdate(String.valueOf(sql));
} catch (SQLException e) {
e.printStackTrace();
}
この操作で見つかった。
実行中はどこですか?あなたのクラスパスは何ですか?そこには何がありますか?サーブレット・コンテナが関与していますか? jdbcのどのバージョン? – Drew
どのバージョンのJDBCを使用しますか? – appkovacs
あなたの環境の答えや詳細はあまりありません。幸運:p – Drew