HI, I am using jdbcTemplate to update records in a table. For some reason, everytime it tries to do a regular insertion after inserting using a preparedstatement, it hangs.. I have no idea why it's hanging - any idea? Here's my code:
[COLOR="RoyalBlue"][SIZE="3"]
[SIZE]Code:keyHolder = new GeneratedKeyHolder(); int addressUpdateCount = jdbcTemplate.update( new PreparedStatementCreator() { String addressSql = "INSERT INTO Address(addressTypeId, address1, address2, suiteNo, " + "entryCode, addressCountry, city, state, province, zipCode, " + "postalCode) VALUES(?,?,?,?,?,?,?,?,?,?,?)"; public PreparedStatement createPreparedStatement(Connection con) throws SQLException { //System.out.println(addressSql); PreparedStatement ps = conn.prepareStatement(addressSql, Statement.RETURN_GENERATED_KEYS); ps.setInt(1, getAddressTypeIdByAddressType(customerProfile.getProfileAddress().getAddressType())); ps.setString(2, customerProfile.getProfileAddress().getAddress1()); ps.setString(3, customerProfile.getProfileAddress().getAddress2()); ps.setString(4, customerProfile.getProfileAddress().getSuiteNo()); ps.setString(5, customerProfile.getProfileAddress().getEntryCode()); ps.setString(6, customerProfile.getProfileAddress().getCountry()); ps.setString(7, customerProfile.getProfileAddress().getCity()); ps.setString(8,(customerProfile.getProfileAddress()).getState()); ps.setString(9,null); ps.setString(10, customerProfile.getProfileAddress()).getCode()); ps.setString(11,null); return ps; } },keyHolder); if(addressUpdateCount > 0){ addressId = keyHolder.getKey().intValue(); String sql = "INSERT INTO CustomerProfile(customerId, identifierTypeId, identifier, addressId)" + "VALUES(" + customerId + "," + getIdentifierTypeIdByIdentifierType(customerProfile.getIdentifierType()) + ",'" + customerProfile.getIdentifier() + "'," + addressId + ")"; //System.out.println(sql); HANGS IN THE CODE BELOW jdbcTemplate.update(sql);


Reply With Quote