String sql="insert into note (id,title,author,content) values (not_sque.nextVal,'?','?','?')";
try {
Connection con=connectionFactory.getconnection();
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1, note.getTitle());
ps.setString(2, note.getAuthor());
ps.setString(3, note.getContent());values中的not_sque.nextVal是什么意思?
这样?
String sql="insert into note (id,title,author,content) values (auto_increment,'?','?','?')";
String sql="insert into note (id,title,author,content) values (null,'?','?','?')";
null就行了,mysql会自动生成自增长的值。
String sql="insert into note (id,title,author,content) values (null,?,?,?)";
http://dev.mysql.com/doc/refman/5.1/zh
insert into talbe_name (id,tietle) values (null,'?')
还有"update note set title=?,author=?,concent=? where id=?";
还是"update note set title='?',author='?',concent='?' where id='?'";
恩,我仔细看下官方文档先,谢谢了 ,我结贴。
insert into talbe_name (id,tietle) values (null,'?') 是标准写法!
下一句是"update note set title='?',author='?',concent='?' where id='?'"; 对!
"update note set title=?,author=?,concent=? where id=?"; 错!