public class PoiBuildingDao {
private JdbcTemplate jdbc = EAP.jdbc.getTemplate(Constants.APP_NAME);
/**
* 查询建筑信息
*/
public boolean queryBuildingInfo(Map<String, Object> map) {
String sql = "INSERT INTO TS_DEVICE_CHANGE(DEVICE_ID,CHANGE_DEVICE_ID)VALUES(?,?) ";
KeyHolder keyHolder1 = new GeneratedKeyHolder();
jdbc.update(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(Connection con) throws SQLException {
// 设置返回的主键字段名
PreparedStatement ps = con.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
ps.setString(1, "1");
ps.setString(2, "2");
return ps;
}
}, keyHolder1);
// 获取到插入数据生成的ID
int num = keyHolder1.getKey().intValue();
System.out.println(num);
return num > 0;
}
}