0
try
{
String sql="INSERT INTO `task`(`task`,`time`) VALUES(?,?)";
PreparedStatement stmt=this.connection.prepareStatement(sql);
stmt.setString(1, this.task);
stmt.setInt(2, this.time);
//stmt.
Boolean res= stmt.execute(sql);
}
catch(Exception e)
{
System.err.println(e);
}
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:您的SQL語法錯誤;檢查對應於你的MySQL服務器版本使用附近的正確語法手冊 '?,?)' 在1號線
MySQL中期望的絃樂「價值」沒有價值,所以儘量把?插入引號。 – 2013-03-15 07:35:04
@JevgeniSmirnov:不,不需要它,'PreparedStatement'負責爲你服務。 – jlordo 2013-03-15 07:38:28
@jlordo對於JDBC,你也可能需要反引號,但只有實際需要的地方(就像其他所有MySQL的用法一樣,參見http://dev.mysql.com/doc/refman/5.5/en/identifiers.html) 。 – 2013-03-15 07:40:26