Statement executeUpdate - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Statement executeUpdate method.

This code example shows how to use the following methods:close, executeUpdate
		return rs;
	} 
 
	public int executeUpdate(String sql) throws SQLException {
		Statement stat = conn.createStatement();
		int affected_num = stat.executeUpdate(sql);
 
		if (stat != null) {
			stat.close();
		} 
		return affected_num;
	} 
} 
8
CodeRank
This code example shows how to use the following methods:close, executeUpdate
 
        } 
 
        private void executeUpdate(Connection connection, String query) throws SQLException {
            final Statement statement = connection.createStatement();
            statement.executeUpdate(query);
            statement.close();
        } 
    } 
 
    static final String RESOURCE_LOCATION = VaultDatasourceTestCase.class.getProtectionDomain().getCodeSource().getLocation().getFile()
            + "security/ds-vault/"; 
    static final String VAULT_BLOCK = "ds_TestDS";
    static final String VAULT_BLOCK_WRONG = VAULT_BLOCK + "Wrong";
    static final String RIGHT_PASSWORD = "passwordForVault";
    static final String WRONG_PASSWORD = "wrongPasswordForVault";
 
    /* 
     * Tests that can access to database with right password 
     */ 
8
CodeRank
This code example shows how to use the following methods:close, executeUpdate
            executeUpdate(conn, "INSERT INTO Principals" + dep + " VALUES ('marcus','" + Utils.hashMD5(MARCUS, coding) + "')");
        } 
 
        private void executeUpdate(Connection connection, String query) throws SQLException {
            final Statement statement = connection.createStatement();
            final int updateResult = statement.executeUpdate(query);
            LOGGER.info("Result: " + updateResult + ".  SQL statement: " + query);
            statement.close();
        } 
    } 
 
} 
7
CodeRank
This code example shows how to use the following methods:executeUpdate
	  LOG.info("Executing DDL command :" + sql);
 
	  try 
	  { 
		  stmt = _bootstrapConn.createStatement();
		  int rs = stmt.executeUpdate(sql);
		  DBHelper.commit(_bootstrapConn);
		  LOG.info("Executed Commmand (" + sql + ") with result " + rs);
	  } catch (SQLException s) {
		  DBHelper.rollback(_bootstrapConn);
	  } finally { 
		  DBHelper.close(stmt);
	  } 
  } 
 
 
  public void executeUpdate(String sql)
		  throws SQLException 
  { 
	  Statement stmt = null;
7
CodeRank
This code example shows how to use the following methods:executeUpdate
	public void testMVTable() throws Exception {
		run("org.h2.mvstore.db.MVTableEngine"); 
	} 
 
	private void run(String engine) throws Exception {
		stmt.executeUpdate("DROP TABLE IF EXISTS TestUniqueIndex");
		String sql = "CREATE TABLE IF NOT EXISTS TestUniqueIndex(id int not null PRIMARY KEY, name varchar(20))";
		if (engine != null)
			sql += " ENGINE \"" + engine + "\"";
 
		stmt.executeUpdate(sql);
 
		stmt.executeUpdate("DROP INDEX IF EXISTS idx_name");
		stmt.executeUpdate("CREATE UNIQUE INDEX IF NOT EXISTS idx_name ON TestUniqueIndex(name)");
 
		try { 
			stmt.executeUpdate("insert into TestUniqueIndex(id, name) values(-1, 'a')");
			stmt.executeUpdate("insert into TestUniqueIndex(id, name) values(-2, 'a')");
			stmt.executeUpdate("insert into TestUniqueIndex(id, name) values(1, 'a')");
 

6
CodeRank
This code example shows how to use the following methods:close, executeUpdate
                    "sa", ""); 
            Statement hsqlStmt = null;
 
            hsqlStmt = HsqlConn.createStatement();
 
            int i = hsqlStmt.executeUpdate(table1Stmt);
            assertFalse(i == -1);
            i = hsqlStmt.executeUpdate(table2Stmt);
            assertFalse(i == -1);
            i = hsqlStmt.executeUpdate(insert1Stmt);
            assertFalse(i == -1);
            i = hsqlStmt.executeUpdate(insert2Stmt);
            assertFalse(i == -1);
            i = hsqlStmt.executeUpdate(insert3Stmt);
            assertFalse(i == -1);
            hsqlStmt.close();
 
            // VoltDB Setup 
            String ddl = table1Stmt + ";" + table2Stmt + ";";
 
            pb = new VoltProjectBuilder();
7
CodeRank
This code example shows how to use the following methods:executeUpdate
    public WOComponent executeUpdate() { 
        EOModel m = EOModelGroup.defaultGroup().models().objectAtIndex(0);
        con = ERXJDBCConnectionBroker.connectionBrokerForModel(m).getConnection();
        try { 
            Statement s = con.createStatement();
            int r = s.executeUpdate(sql);
            response = "result: "+r;
        } catch (SQLException e) {
            // TODO Auto-generated catch block 
            e.printStackTrace();
        } finally { 
            ERXJDBCConnectionBroker.connectionBrokerForModel(m).freeConnection(con);
        } 
        return context().page(); 
    } 
 
     
    @Override 
    public void appendToResponse(WOResponse r, WOContext c) {
        if (session().objectForKey("ERXDatabaseConsole.enabled") != null) { 
6
CodeRank
This code example shows how to use the following methods:executeUpdate
			con = GetConnection("JunkDB");
 
			Statement stmt = con.createStatement();
 
			try { 
				stmt.executeUpdate("DROP TABLE myTable");
			} catch (SQLException e) {
				System.out.println("No existing table to delete");
			} 
 
			stmt.executeUpdate("CREATE TABLE myTable(test_id int," + "test_val char(15) not null)");
 
			stmt.executeUpdate("INSERT INTO myTable(test_id, " + "test_val) VALUES(1,'One')");
			stmt.executeUpdate("INSERT INTO myTable(test_id, " + "test_val) VALUES(2,'Two')");
			stmt.executeUpdate("INSERT INTO myTable(test_id, " + "test_val) VALUES(3,'Three')");
			stmt.executeUpdate("INSERT INTO myTable(test_id, " + "test_val) VALUES(4,'Four')");
			stmt.executeUpdate("INSERT INTO myTable(test_id, " + "test_val) VALUES(5,'Five')");
 
			stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
 

6
CodeRank
This code example shows how to use the following methods:close, execute, executeUpdate
            s2 = c2.createStatement();
             
            s1.execute("create table "+TABLE1+" ( id INTEGER, foo INTEGER )");
            s1.executeUpdate("insert into "+TABLE1+" (id, foo) values (1, 1)");
            c1.commit();
            s2.execute("create table "+TABLE2+" ( id INTEGER, foo INTEGER )");
            s2.executeUpdate("insert into "+TABLE2+" (id, foo) values (1, 1)");
            c2.commit();
             
            setupDone = true;
        } 
        finally 
        { 
            if (s1 != null) s1.close();
            if (s2 != null) s2.close();
            if (c1 != null) c1.close();
            if (c2 != null) c2.close();
        } 
    } 
     
6
CodeRank
This code example shows how to use the following methods:executeQuery, executeUpdate
	public void testMVTable() throws Exception {
		run("org.h2.mvstore.db.MVTableEngine"); 
	} 
 
	private void run(String engine) throws Exception {
		stmt.executeUpdate("DROP TABLE IF EXISTS TestMVSecondaryIndex");
		String sql = "CREATE TABLE IF NOT EXISTS TestMVSecondaryIndex(id int not null PRIMARY KEY, name varchar(20))";
		if (engine != null)
			sql += " ENGINE \"" + engine + "\"";
 
		stmt.executeUpdate(sql);
 
		stmt.executeUpdate("CREATE INDEX IF NOT EXISTS idx_name ON TestMVSecondaryIndex(name)");
 
		stmt.executeUpdate("insert into TestMVSecondaryIndex(id, name) values(-1, 'a')");
		stmt.executeUpdate("insert into TestMVSecondaryIndex(id, name) values(-2, 'a')");
		stmt.executeUpdate("insert into TestMVSecondaryIndex(id, name) values(1, 'b')");
		stmt.executeUpdate("insert into TestMVSecondaryIndex(id, name) values(2, 'b')");
 
		count(2, "name='b'"); 

6
CodeRank

Related Statement executeUpdate Questions & Answers:

executeUpdate Method Overview
Executes the given SQL statement and signals the driver that the auto-generated keys indicated in the given array should be made available for retrieval.
See Code Examples for other Java 8 Statement Methods: