JavaWeb 学习笔记 (三)遇到的一些问题

#MyEclipse Tomcat v7.0 启动时,Console提示:警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:learnStruts02' did not find a matching property.

  1. 这只是一个警告,不用管,不会影响运行
  2. 参考这里:stackoverflow 

#提示如下错误:HTTP Status 500 - java.sql.SQLException: Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate(), Statement.executeLargeUpdate() or Connection.prepareStatement().

  1. 貌似从5.1.7版本之后的mysql-connector增加了返回GeneratedKeys的条件, 如果需要返回GeneratedKeys, 则PreparedStatement需要显示添加一个参数Statement.RETURN_GENERATED_KEYS。
  2. 代码按提示改成如下即可:
    preSmt = conn.prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
    				
posted @ 2016-08-30 17:15  树.Code  阅读(314)  评论(0编辑  收藏  举报