List of usage examples for java.sql Statement executeUpdate
int executeUpdate(String sql) throws SQLException;
INSERT
, UPDATE
, or DELETE
statement or an SQL statement that returns nothing, such as an SQL DDL statement. From source file:com.aerothai.database.unit.UnitService.java
/** * Method to check whether uname and pwd combination are correct * * @param uname/*from ww w. j ava 2 s . com*/ * @param pwd * @return * @throws Exception */ public String updateUnit(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.unit.UnitService.java
/** * Method to check whether uname and pwd combination are correct * //from w ww .j a v a 2s. c o m * @param uname * @param pwd * @return * @throws Exception */ public String deleteUnit(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.unit.UnitService.java
/** * Method to check whether uname and pwd combination are correct * /*from w ww .jav a2 s . c om*/ * @param uname * @param pwd * @return * @throws Exception */ public String createUnit(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.radiosignal.RadiosignalService.java
/** * Method to check whether uname and pwd combination are correct * * @param uname// www .j av a 2s . c o m * @param pwd * @return * @throws Exception */ public String updateRadiosignal(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.radiosignal.RadiosignalService.java
/** * Method to check whether uname and pwd combination are correct * /*from w w w . j a v a 2 s .c o m*/ * @param uname * @param pwd * @return * @throws Exception */ public String deleteRadiosignal(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:net.certifi.audittablegen.HsqldbDMR.java
void createTestTable() throws SQLException { //logger.debug("dataSourse is NOT null: {}", dmd.getURL()); String SQL = "Create table test1 (test1Id integer not null identity, test1Data integer )"; try {//from w w w. j a va 2 s . c o m Connection conn = dataSource.getConnection(); logger.trace("here1"); if (dataSource == null) { logger.warn("dataSourse is null"); logger.trace("here2"); } else { logger.debug("dataSourse is NOT null: {}", dataSource.toString()); logger.trace("here3"); } Statement stmt = conn.createStatement(); if (stmt == null) { logger.warn("stmt is null"); } else { logger.debug("stmt is NOT null"); } stmt.executeUpdate(SQL); stmt.executeUpdate("insert into test1 (test1Data) values 1"); stmt.close(); conn.close(); } catch (SQLException ex) { logger.error("Error ...", ex); } }
From source file:com.aerothai.database.radiosignal.RadiosignalService.java
/** * Method to check whether uname and pwd combination are correct * /* w ww .j av a 2s.c o m*/ * @param uname * @param pwd * @return * @throws Exception */ public String createRadiosignal(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(); }