Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int test(int pId, String pName, String pCity, int pSalary) {
- int retVal = 1;
- String connURL = "jdbc:mysql://localhost:3306/test";
- String query = "SELECT * FROM person LIMIT 1";
- try (Connection conn = DriverManager.getConnection(connURL,"***", "***");
- PreparedStatement pstmt = conn.prepareStatement(
- query,
- ResultSet.TYPE_FORWARD_ONLY,
- ResultSet.CONCUR_UPDATABLE);
- ResultSet res = pstmt.executeQuery() )
- {
- res.moveToInsertRow();
- res.updateInt("id", pId);
- res.updateString("name", pName);
- res.updateString("city", pCity);
- res.updateInt("salary", pSalary);
- res.insertRow();
- } catch (SQLException ex) {
- retVal = 0;
- }
- return retVal;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement