insert/update/delete

@param sql
@param args
@return
506969
public static int update(String sql, Object... args) {
		int result = 0;
		Connection con = getconnnection();
		PreparedStatement ps = null;
		try {
			ps = con.prepareStatement(sql);
			if (args != null) {
				for (int i = 0; i < args.length; i++) {
					ps.setObject((i + 1), args[i]);
				}
			}
			result = ps.executeUpdate();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			close(ps, con);
		}

		return result;
	}
488938
public List<Object> querySingleRowResults(String sql, String[] args) {
		return db.querySingleRowResults(sql, args);
	}
1255888
public static List<Map<String, Object>> getListMap(String sql, Object... arg) {
        Connection connection = JDBCUtils.getConnection();
        PreparedStatement ps = null;
        ResultSet result = null;
        List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
        try {
            ps = connection.prepareStatement(sql);
            for (int i = 0; i < arg.length; i++) {
                ps.setObject(i + 1, arg[i]);
            }

            result = ps.executeQuery();
            listMap = DBUtils.handleResultSetToMapList(result, listMap);
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
            JDBCUtils.release(result, ps, connection);
        }
        return listMap;
    }
805111
public Object querySingleResult(String sql, String[] args, int column) {
		return db.querySingleResult(sql, args, column);
	}
682769
static int deleteAll(CallInfo callInfo, Table table, String where, Object... args) {
    final DB db = table.getDB();

    return  db.access(callInfo, () -> {
      table.setDirtyStatus(true);
      String sql = 
          DELETE_FROM_ + table.getName() +
          WHERE_ + where;
      db.logSetup(callInfo, sql);
      try (WrappedStatement ws = db.compile(sql)) {
        PreparedStatement deleteStmt = ws.getStatement();
        if (args != null && args.length > 0) {
          for (int i=0; i < args.length; i++) {
            deleteStmt.setObject(i + 1, args[i]);
          }
        }
        return deleteStmt.executeUpdate(); 
      }
    });
  }
1257073
def _execute(sql, name = nil)
      if ::ActiveRecord::ConnectionAdapters::JdbcConnection::select?(sql)
        @connection.execute_query(sql)
      elsif ::ActiveRecord::ConnectionAdapters::JdbcConnection::insert?(sql)
        insert(sql, name)
      else
        @connection.execute_update(sql)
      end
    end
134366
public function setSQL($sql, array $args=[]) {
		$this->sql = $sql;
		$this->args = $args;

		$this->message = $this->getMessage();

		if(strlen($sql) > 2048)
			return $this;
		$msg = '<br/>'."\n".'SQL: '.$sql;
		if(count($args) > 0) {
			$msg .= ' ('.implode(', ', $args).')';
			if(strlen($msg) > 2048)
				return $this;
		}
		$this->message .= $msg;

		return $this;
	}
743477
public @NotNull QueryBuilder append(@NotNull String sql, Object... args) {
        return append(sql, asList(args));
    }
761673
public static final void appendValueToSql(StringBuilder sql, Object value) {
        if (value == null) {
            sql.append("NULL");
        } else if (value instanceof Boolean) {
            Boolean bool = (Boolean)value;
            if (bool) {
                sql.append('1');
            } else {
                sql.append('0');
            }
        } else {
            appendEscapedSQLString(sql, value.toString());
        }
    }
1025885
public ResultSet query(String sql, String[] args) {
		return SQLUtils.query(connection, sql, args);
	}
1083069
def _execute(self, sql, args):
        
        sql = sql.lower().strip()
        args = args or ()
        tmp = sql[:6]
        with (yield self._pool.Connection()) as conn:
            try:
                with conn.cursor() as cursor:
                    yield cursor.execute(sql, args=args)
                    if tmp == 'select':
                        datas = cursor.fetchall()   
                        return datas
            except Exception as e:
                err = traceback.format_exc()
                print(err)
                if tmp in ['insert', 'update', 'delete']:
                    yield conn.rollback()
            else:
                if tmp == 'insert':
                    insertId = conn.insert_id()
                    yield conn.commit()
                    # 返回插入的主键id
                    return insertId
                elif tmp in ['update', 'delete']:
                    yield conn.commit()
796448
public static Map<String, Object> queryForMap(String sql, Object... args) {
		Map<String, Object> result = new HashMap<String, Object>();
		List<Map<String, Object>> list = queryForList(sql, args);
		if (list.size() > 0) {
			result = list.get(0);
		}
		return result;
	}
556094
private static function run_sql( $sql_cmd, $assoc_args = array(), $add_database = false ) {
		$default_assoc_args = array(
			'host' => self::$db_settings['dbhost'],
			'user' => self::$db_settings['dbuser'],
			'pass' => self::$db_settings['dbpass'],
		);
		if ( $add_database ) {
			$sql_cmd .= ' ' . escapeshellarg( self::$db_settings['dbname'] );
		}
		$start_time = microtime( true );
		Utils\run_mysql_command( $sql_cmd, array_merge( $assoc_args, $default_assoc_args ) );
		if ( self::$log_run_times ) {
			self::log_proc_method_run_time( 'run_sql ' . $sql_cmd, $start_time );
		}
	}
1047928
public int execute(String sql, Object... params) {
        Connection conn = getConn();
        try {
            return conn.createQuery(sql)
                    .withParams(params)
                    .executeUpdate()
                    .getResult();
        } finally {
            this.closeConn(conn);
            this.clean(conn);
        }
    }
429401
public int insert(String sql, Object value) {
        Class<?> parameterType = value != null ? value.getClass() : null;
        String msId = msUtils.insertDynamic(sql, parameterType);
        return sqlSession.insert(msId, value);
    }
679903
public synchronized void insert (Connection conn, T[] objects)
        throws SQLException
    {
        StringBuilder sql = new StringBuilder(
            "insert into " + name + " (" + listOfFields + ") values (?");
        for (int i = 1; i < nColumns; i++) {
            sql.append(",?");
        }
        sql.append(")");
        PreparedStatement insertStmt = conn.prepareStatement(sql.toString());
        for (int i = 0; i < objects.length; i++) {
            bindUpdateVariables(insertStmt, objects[i], null);
            insertStmt.addBatch();
        }
        insertStmt.executeBatch();
        insertStmt.close();
    }
155894
public List<List<Object>> queryResults(String sql, String[] args) {
		return db.queryResults(sql, args);
	}