daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Jun 21st, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public int insertDistrict(String string, int i, int i1, int i2) {
  2.        try {
  3.            
  4.             Connection con = DB.getInstance().getConnection();
  5.             String sql = "select IdG from Grad where IdG =" + i;
  6.             Statement stm = con.createStatement();
  7.             ResultSet r = stm.executeQuery(sql);
  8.             if(r.next()){
  9.             PreparedStatement ps = con.prepareStatement("insert into Opstina (naziv,x,y,IdG) values (?,?,?,?)");
  10.             ps.setString(1, string);
  11.             ps.setInt(2, i);
  12.             ps.setInt(3, i1);
  13.             ps.setInt(4, i2);
  14.  
  15.             ps.execute();
  16.             ResultSet rs = ps.getGeneratedKeys();
  17.             rs.next();
  18.             return rs.getInt(1);
  19.             }
  20.            
  21.             return -1;
  22.            
  23.         } catch (SQLException ex) {
  24.             Logger.getLogger(jp140452_CityOperations.class.getName()).log(Level.SEVERE, null, ex);
  25.             return -1;
  26.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top