Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int insertDistrict(String string, int i, int i1, int i2) {
- try {
- Connection con = DB.getInstance().getConnection();
- String sql = "select IdG from Grad where IdG =" + i;
- Statement stm = con.createStatement();
- ResultSet r = stm.executeQuery(sql);
- if(r.next()){
- PreparedStatement ps = con.prepareStatement("insert into Opstina (naziv,x,y,IdG) values (?,?,?,?)");
- ps.setString(1, string);
- ps.setInt(2, i);
- ps.setInt(3, i1);
- ps.setInt(4, i2);
- ps.execute();
- ResultSet rs = ps.getGeneratedKeys();
- rs.next();
- return rs.getInt(1);
- }
- return -1;
- } catch (SQLException ex) {
- Logger.getLogger(jp140452_CityOperations.class.getName()).log(Level.SEVERE, null, ex);
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement