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.role.RoleService.java
/** * Method to check whether uname and pwd combination are correct * // w w w . j a va 2s .co m * @param uname * @param pwd * @return * @throws Exception */ public String deleteRole(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.status.StatusService.java
/** * Method to check whether uname and pwd combination are correct * * @param uname//from w w w. j av a 2 s.c o m * @param pwd * @return * @throws Exception */ public String updateStatus(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.status.StatusService.java
/** * Method to check whether uname and pwd combination are correct * /*w w w . j a va 2 s . c o m*/ * @param uname * @param pwd * @return * @throws Exception */ public String deleteStatus(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.role.RoleService.java
/** * Method to check whether uname and pwd combination are correct * /*from w w w. j a v a 2 s .co m*/ * @param uname * @param pwd * @return * @throws Exception */ public String createRole(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.servicemethod.ServicemethodService.java
/** * Method to check whether uname and pwd combination are correct * * @param uname//from w w w . j a v a2 s . co m * @param pwd * @return * @throws Exception */ public String updateServicemethod(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.servicemethod.ServicemethodService.java
/** * Method to check whether uname and pwd combination are correct * /*from w w w . j a v a2 s.c o m*/ * @param uname * @param pwd * @return * @throws Exception */ public String deleteServicemethod(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.servicetype.ServicetypeService.java
/** * Method to check whether uname and pwd combination are correct * * @param uname/*from w w w . ja v a 2s . c o m*/ * @param pwd * @return * @throws Exception */ public String updateServicetype(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.servicetype.ServicetypeService.java
/** * Method to check whether uname and pwd combination are correct * /* ww w . ja v a2 s . c om*/ * @param uname * @param pwd * @return * @throws Exception */ public String deleteServicetype(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.status.StatusService.java
/** * Method to check whether uname and pwd combination are correct * /*from ww w . j a va 2 s .co m*/ * @param uname * @param pwd * @return * @throws Exception */ public String createStatus(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.cloudera.sqoop.testutil.HsqldbTestServer.java
/** * Fill the table with some data.//w ww . j a v a 2 s. c om */ public void populateData() throws SQLException { Connection connection = null; Statement st = null; try { connection = getConnection(); st = connection.createStatement(); st.executeUpdate("INSERT INTO " + DUMMY_TABLE_NAME + " VALUES(1, 8)"); st.executeUpdate("INSERT INTO " + DUMMY_TABLE_NAME + " VALUES(3, 6)"); st.executeUpdate("INSERT INTO " + DUMMY_TABLE_NAME + " VALUES(5, 4)"); st.executeUpdate("INSERT INTO " + DUMMY_TABLE_NAME + " VALUES(7, 2)"); connection.commit(); } finally { if (null != st) { st.close(); } if (null != connection) { connection.close(); } } }