Example usage for java.sql Statement executeUpdate

List of usage examples for java.sql Statement executeUpdate

Introduction

In this page you can find the example usage for java.sql Statement executeUpdate.

Prototype

int executeUpdate(String sql) throws SQLException;

Source Link

Document

Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.

Usage

From source file:com.aerothai.database.model.ModelService.java

/**
 * Method to check whether uname and pwd combination are correct
 * /* w w w . j  a v a2 s  .  co  m*/
 * @param uname
 * @param pwd
 * @return
 * @throws Exception
 */
public String deleteModel(String query) throws Exception {

    Connection dbConn = null;
    JSONObject obj = new JSONObject();

    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        System.out.println(query);
        stmt.executeUpdate(query);

        obj.put("tag", "delete");
        obj.put("msg", "done");
        obj.put("status", true);

    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj.toJSONString();
}

From source file:com.aerothai.database.accessory.AccessoryService.java

/**
 * Method to check whether uname and pwd combination are correct
 * //from w w  w  .  j  a  va  2  s.  c o m
 * @param uname
 * @param pwd
 * @return
 * @throws Exception
 */
public String createAccessory(String query) throws Exception {

    Connection dbConn = null;
    JSONObject obj = new JSONObject();
    obj.put("msg", "error");
    obj.put("status", false);
    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        System.out.println(query);
        stmt.executeUpdate(query);

        obj.put("tag", "create");
        obj.put("msg", "done");
        obj.put("status", true);

    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj.toJSONString();
}

From source file:com.aerothai.database.model.ModelService.java

/**
 * Method to check whether uname and pwd combination are correct
 * //  w  ww  .j ava2  s.c o  m
 * @param uname
 * @param pwd
 * @return
 * @throws Exception
 */
public String createModel(String query) throws Exception {

    Connection dbConn = null;
    JSONObject obj = new JSONObject();
    obj.put("msg", "error");
    obj.put("status", false);
    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        System.out.println(query);
        stmt.executeUpdate(query);

        obj.put("tag", "create");
        obj.put("msg", "done");
        obj.put("status", true);

    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj.toJSONString();
}

From source file:com.aerothai.database.jobevaluate.JobevaluateService.java

/**
* Method to check whether uname and pwd combination are correct
* 
* @param uname/*from  w  w  w  . j a  va  2s  .co m*/
* @param pwd
* @return
* @throws Exception
*/
public String updateJobevaluate(String query) throws Exception {

    Connection dbConn = null;
    JSONObject obj = new JSONObject();

    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        System.out.println(query);
        stmt.executeUpdate(query);

        obj.put("tag", "update");
        obj.put("msg", "done");
        obj.put("status", true);

    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj.toJSONString();
}

From source file:com.aerothai.database.jobevaluate.JobevaluateService.java

/**
 * Method to check whether uname and pwd combination are correct
 * /*w w  w  .  j  av  a 2s .  co  m*/
 * @param uname
 * @param pwd
 * @return
 * @throws Exception
 */
public String deleteJobevaluate(String query) throws Exception {

    Connection dbConn = null;
    JSONObject obj = new JSONObject();

    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        System.out.println(query);
        stmt.executeUpdate(query);

        obj.put("tag", "delete");
        obj.put("msg", "done");
        obj.put("status", true);

    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj.toJSONString();
}

From source file:com.aerothai.database.jobevaluate.JobevaluateService.java

/**
 * Method to check whether uname and pwd combination are correct
 * /*  w w w  .j a  va2s .  c  o  m*/
 * @param uname
 * @param pwd
 * @return
 * @throws Exception
 */
public String createJobevaluate(String query) throws Exception {

    Connection dbConn = null;
    JSONObject obj = new JSONObject();
    obj.put("msg", "error");
    obj.put("status", false);
    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        System.out.println(query);
        stmt.executeUpdate(query);

        obj.put("tag", "create");
        obj.put("msg", "done");
        obj.put("status", true);

    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj.toJSONString();
}

From source file:com.aerothai.database.sparepart.SparepartService.java

/**
* Method to check whether uname and pwd combination are correct
* 
* @param uname//w  w w.j a v a2 s  .  co m
* @param pwd
* @return
* @throws Exception
*/
public String updateSparepart(String query) throws Exception {

    Connection dbConn = null;
    JSONObject obj = new JSONObject();

    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        System.out.println(query);
        stmt.executeUpdate(query);

        obj.put("tag", "update");
        obj.put("msg", "done");
        obj.put("status", true);

    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj.toJSONString();
}

From source file:com.aerothai.database.sparepart.SparepartService.java

/**
 * Method to check whether uname and pwd combination are correct
 * //from   w  w  w.j av a 2s  .c  o  m
 * @param uname
 * @param pwd
 * @return
 * @throws Exception
 */
public String deleteSparepart(String query) throws Exception {

    Connection dbConn = null;
    JSONObject obj = new JSONObject();

    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        System.out.println(query);
        stmt.executeUpdate(query);

        obj.put("tag", "delete");
        obj.put("msg", "done");
        obj.put("status", true);

    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj.toJSONString();
}

From source file:io.seqware.pipeline.plugins.FileProvenanceQueryTool.java

private void bulkImportH2(StringBuilder tableCreateBuilder, Connection connection, Path importFile)
        throws SQLException {
    tableCreateBuilder.append("AS SELECT * FROM CSVREAD('").append(importFile.toString())
            .append("', null, 'fieldSeparator=\t')");
    Log.debug("Table creation query is: " + tableCreateBuilder.toString());
    Statement createTableStatement = null;
    try {//w  w w.java  2s. c  o m
        createTableStatement = connection.createStatement();
        createTableStatement.executeUpdate(tableCreateBuilder.toString());
    } finally {
        DbUtils.closeQuietly(createTableStatement);
    }
}

From source file:com.aerothai.database.sparepart.SparepartService.java

/**
 * Method to check whether uname and pwd combination are correct
 * /*from   w ww  . j a  v a 2s  .  co  m*/
 * @param uname
 * @param pwd
 * @return
 * @throws Exception
 */
public String createSparepart(String query) throws Exception {

    Connection dbConn = null;
    JSONObject obj = new JSONObject();
    obj.put("msg", "error");
    obj.put("status", false);
    try {
        dbConn = DBConnection.createConnection();

        Statement stmt = dbConn.createStatement();
        System.out.println(query);
        stmt.executeUpdate(query);

        obj.put("tag", "create");
        obj.put("msg", "done");
        obj.put("status", true);

    } catch (SQLException sqle) {
        throw sqle;
    } catch (Exception e) {
        // TODO Auto-generated catch block
        if (dbConn != null) {
            dbConn.close();
        }
        throw e;
    } finally {
        if (dbConn != null) {
            dbConn.close();
        }
    }
    return obj.toJSONString();
}