mysql jarパッケージバージョン更新の問題


最近、以前書いたコードを再構築し、再構築の過程でmysqlのjarパッケージを5.0にすることが一時興った.4を5.1に更新.16、プロジェクトを開始した後、いくつかの異常が発生したことを発見しました.まず、データ挿入時にプライマリキーを取得する際に異常:orgを投げ出す.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL []; SQL state [S1009]; error code [0]; Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate() or Connection.prepareStatement().; nested exception is java.sql.SQLException: Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate() or Connection.prepareStatement().
解決方法:PreparedStatementps=con.prepareStatement(sql);PreparedStatementps=conに変更します.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(new PreparedStatementCreator() {
  @Override
  public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
      PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
      return ps;
  }
}, keyHolder);

 
次に、同じテーブルで接続クエリーを行うときに、カラムが見つからない例外を常に放出します.
Nested in org.springframework.jdbc.InvalidResultSetAccessException:カラム名が無効です.nested exception is java.sql.SQLException:無効な列名:java.sql.SQLException:無効なカラム名
 
このクエリのsql文は、selectt t 1である.a, t1.b, t1.c, t1.d,  t1.e,  t2.a x, t2.b y, t2.c z, from table_a t1 left join table_a t2 on t1.c = t2.a where t1.a=?
SqlRowSet srs = jdbcTemplate.queryForRowSet(sql);
if(srs.next()){
    ...
    srs.getInt("x");
    ...
}

srsに実行する.getInt("x")コードの場合、上記の異常が投げ出す、事実上、すべてのt 2列に列名が無効なエラーが発生し、この問題はまだ解決していないが、jarパッケージを前のバージョン5.0に戻す.4すべて正常になりました.
今回は、やむを得ない状況で簡単にプロジェクトの環境をアップグレードしないで、もし本当にアップグレードするならば、プロジェクトの中でアップグレードした関連機能モジュールを再テストしなければなりません.