How to confirm the insert query is a success?
<p>I am inserting into the database with foll0wing code and it's working fine as I can see the data populates in the db, however I want to capture the result programmatically whether it was a success or failure</p>

<p>1) Here is the code to insert</p>

<pre><code>public void SignUp(String last_name, String first_name, String email,
        String password, String confirm_password, String phone) {

    Connect connect = new Connect();
    Connection conn = connect.Connection();
    Statement stmt = conn.createStatement();

    String query = "INSERT INTO users VALUES(NULL,('" + last_name + "'),('"
            + first_name + "'),('" + email + "'),('" + password + "'),('"
            + confirm_password + "'),('" + phone + "'))";
    stmt.executeUpdate(query);
    conn.close();

}
</code></pre>

<p>2) Here is the code I used to connect </p>

<pre><code>public Connection Connection() {

    Connection conn = null;

    try {
        String userName = "admin";
        String password = "admin";
        String url = "jdbc:mysql://localhost/project";
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        conn = DriverManager.getConnection(url, userName, password);

        System.out.println("\n Database connection established");

    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("\n Cannot connect to database server");

    }
}
</code></pre>
