不,这是行不通的(不适用于真实数据):
String sql = "INSERT INTO course " + "VALUES (course_pre, course_desc, course_chair)"; stmt.executeUpdate(sql);
更改为:
String sql = "INSERT INTO course (course_pre, course_desc, course_chair)" + "VALUES (?, ?, ?)";
使用该sql创建一个PreparedStatment,并使用索引插入值:
PreparedStatement preparedStatement = conn.prepareStatement(sql);preparedStatement.setString(1, "Test");preparedStatement.setString(2, "Test2");preparedStatement.setString(3, "Test3");preparedStatement.executeUpdate();
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)