Code example for PreparedStatement

Methods: executeUpdate, setBoolean, setInt, setString

0
					String sqlQuery = "INSERT INTO sixeyegamesusers VALUES(null,?,?,?,?,?) ";
 
					ps = connection.prepareStatement(sqlQuery,
							PreparedStatement.RETURN_GENERATED_KEYS);
 
					ps.setString(1, _userName);
 
					ps.setString(2, _userName);
 
					ps.setString(3, _userPassw);
 
					ps.setBoolean(4, true);
					 
					ps.setInt(5, 0);
					// test if device exist 
					int row = 0;
					if (row != 0) {
						System.out.println(" logIn : created a new User");
					} else { 
						System.out.println(" logIn : failed to create a new User");
					} 
					try { 
						row = ps.executeUpdate();
					} catch (SQLException e) {
						System.out.println("e.getMessage() = " + e.getMessage());
						return "-1"; 
					}