我在 mySQL 中创建了下表(to_do) : td_id(int),td_day(int),td_month(int),td_year(int),to_do(varchar),td_done(boolean)
td_id 字段设置为自动递增模式
在 NetBeans 中运行以下代码时,我收到一条错误消息,提示“‘字段列表’中的未知列‘新年派对’”
有人能告诉我如何让代码工作吗?提前致谢。
Connection conn1;
try{
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/myproject?" +
"user=root&password=abcd";
conn1 = DriverManager.getConnection(url);
int datevar=31,monthar3=12,yearvar1=2012;
String data=”new year party”;
String strSQL = "INSERT INTO to_do(td_day,td_month,td_year,to_do,td_done) VALUES (“+datevar1+","+monthvar3+","+yearvar1+","+data+",0)";
Statement stmt1 = conn1.createStatement();
int StringrowsEffected = stmt1.executeUpdate(strSQL);
conn1.close();
}
catch ( Exception e) {
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}