Code example for ResultSet

Methods: first, getInt

0
try{ 
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/cutPlanner","root","");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("select "+sloup+" from "+tab+" order by "+sloup+" desc;");
 
if (rs.first()){id = rs.getInt(1)+1;}
else id = 1;
 
 
}catch(Exception e){ System.out.println("Chyba volani, neprihlaseno");
System.out.println(e.toString());}
         
    }   
     
     
}