public void updateUserInfo(UserInfo user) throws Exception {
        Connection conn = null;
        // get connection from data source
        try {
            conn = datasource.getConnection();
        } catch (SQLException e) {
            throw new RuntimeException("Could not get JDBC Connection", e);
        }

        PreparedStatement stmt = null;
        try {
            boolean auto = conn.getAutoCommit();
            LOG.info("default connection auto commit state is {}.", auto);

            // set auto commit is false, begin transaction
            conn.setAutoCommit(false);

            String sql = "update user set name=?, age=? where user_id=?";
            stmt = conn.prepareStatement(sql);
            stmt.setString(1, user.getName());
            stmt.setInt(2, user.getAge());
            stmt.setInt(3, user.getUserId());
            stmt.executeUpdate();

            // commit transaction
            conn.commit();
        } catch (Exception e) {
            try {
                conn.rollback();
            } catch (SQLException se) {
            }

            throw e;
        } finally {
            try {
                if (stmt != null) {
                    stmt.close();
                }
            } catch (SQLException e) {
            }

            try {
                if (conn != null) {
                    conn.close();
                }
            } catch (SQLException e) {
            }
        }

    }