/* (non-Javadoc)
@see org.parosproxy.paros.db.paros.TableTag#insert(long, java.lang.String)
173677
@Override
	public synchronized RecordTag insert(long historyId, String tag) throws DatabaseException {
        try {
			psInsertTag.setLong(1, historyId);
			psInsertTag.setString(2, tag);
			psInsertTag.executeUpdate();
			
			try (ResultSet rs = psGetIdLastInsert.executeQuery()) {
				rs.next();
				long id = rs.getLong(1);
				return read(id);
			}
		} catch (SQLException e) {
			throw new DatabaseException(e);
		}
    }
581272
private void generateInsert(M2MEntity entity, String packageName) {
		if (!isMethodAlreadyDefined(entity, "insert")) {
			// @formatter:off
			MethodSpec methodSpec = MethodSpec.methodBuilder("insert").addModifiers(Modifier.PUBLIC)
					.addModifiers(Modifier.ABSTRACT).addAnnotation(AnnotationSpec.builder(BindSqlInsert.class).build())
					.addParameter(ParameterSpec.builder(TypeUtility.className(packageName, entity.name), "bean")
							.addAnnotation(
									AnnotationSpec.builder(BindSqlParam.class).addMember("value", "$S", "bean").build())
							.build())
					.returns(Integer.TYPE).build();
			// @formatter:on
			classBuilder.addMethod(methodSpec);
		}
	}
174991
static void insertPreLongs(final WritableMemory wmem, final int preLongs) {
    final int curByte = wmem.getByte(PREAMBLE_LONGS_BYTE);
    final int mask = 0x3F;
    final byte newByte = (byte) ((preLongs & mask) | (~mask & curByte));
    wmem.putByte(PREAMBLE_LONGS_BYTE, newByte);
  }
1217495
@Override
  public <N,V> MutationResult insert(final K key, final String cf, final HColumn<N,V> c) {
    addInsertion(key, cf, c);
    return execute();
  }
1174406
public int insert(String sql,Object[] params,String autoGeneratedColumnName)
			throws DataAccessException{
		//dynamic change catalog name
		sql = changeCatalog(sql);
		
		ReturnIdPreparedStatementCreator psc = new ReturnIdPreparedStatementCreator(sql, params, autoGeneratedColumnName);
		KeyHolder keyHolder = new GeneratedKeyHolder();
		try{
			jdbcTemplate.update(psc, keyHolder);
		}catch(DataAccessException e){
			StringBuilder sb = new StringBuilder();
			sb.append("[");
			for(Object p:params){
				sb.append(p + " | ");
			}
			sb.append("]");
			logger.error("Error SQL: " + sql + " Params: " + sb.toString());
			throw e;
		}
		
		return keyHolder.getKey().intValue();
	}
497038
@Override
    public BoundStatement bindInsert(PreparedStatement statement, P pojo, int ttl) {
        List<Object> parameters = new LinkedList<>();
        keyBinding.collectParameters(pojo, parameters);
        facetBindings.forEach(facetBinding -> facetBinding.collectParameters(pojo, parameters));
        parameters.add(ttl);
        return bind(statement, parameters);
    }
519019
@Override
    public Long append(final String key, final String value) {
        return this.d_append(key, value).getResult();
    }
223195
@Override
  public final <T> void insertEntity(final Map<String, Object> pAddParam,
    final T pEntity) throws Exception {
    ColumnsValues columnsValues = evalColumnsValues(pAddParam, pEntity);
    columnsValues.getLongsMap().remove(ISrvOrm.VERSIONOLD_NAME);
    Long result = getSrvDatabase().executeInsert(pEntity.getClass()
      .getSimpleName().toUpperCase(), columnsValues);
    String[] idName = columnsValues.getIdColumnsNames();
    if (idName.length == 1) { // if non-composite PK
      Field fieldId = getUtlReflection()
                .retrieveField(pEntity.getClass(), idName[0]);
      fieldId.setAccessible(true);
      Object idValue = fieldId.get(pEntity);
      if (idValue == null) {
        //It must be an autogenerated Integer or Long ID
        if (fieldId.getType() == Long.class) {
          fieldId.set(pEntity, result);
        } else if (fieldId.getType() == Integer.class) {
          fieldId.set(pEntity, result.intValue());
        } else {
          String msg = "There is no rule to fill ID "
            + fieldId.getName()
              + " of " + fieldId.getType() + " in "
                + pEntity;
          throw new ExceptionWithCode(ExceptionWithCode.NOT_YET_IMPLEMENTED,
            msg);
        }
      }
    }
  }
580479
@Override
	public synchronized RecordParam insert(String site, String type, String name, int used, String flags,
			String values) throws DatabaseException {
    	SqlPreparedStatementWrapper psInsert = null;
        try {
        	psInsert = DbSQL.getSingleton().getPreparedStatement("param.ps.insert");
			psInsert.getPs().setString(1, site);
			psInsert.getPs().setString(2, type);
			psInsert.getPs().setString(3, name);
			psInsert.getPs().setInt(4, used);
			psInsert.getPs().setString(5, flags);
			psInsert.getPs().setString(6, values);
			psInsert.getPs().executeUpdate();
			
			long id;
			try (ResultSet rs = psInsert.getLastInsertedId()) {
				rs.next();
				id = rs.getLong(1);
			}
			return read(id);
		} catch (SQLException e) {
			throw new DatabaseException(e);
		} finally {
			DbSQL.getSingleton().releasePreparedStatement(psInsert);
		}
    }
168405
public void insert(String str, int lineno, int colno) {
		final String sourceMethod = "insert"; //$NON-NLS-1$
		if (isTraceLogging) {
			log.entering(JSSource.class.getName(), sourceMethod, new Object[]{str, lineno, colno});
		}
		PositionLocator locator = new PositionLocator(lineno, colno);
		locator.insert(str);
		if (isTraceLogging) {
			log.exiting(JSSource.class.getName(), sourceMethod, "String \"" + str + "\" inserted at " + mid + "(" + lineno + "," + colno + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
		}
	}
677522
private static void insertJsonColumn(CqlSession session) {

    User alice = new User("alice", 30);
    User bob = new User("bob", 35);

    // Build and execute a simple statement

    Statement stmt =
        insertInto("examples", "json_jackson_column")
            .value("id", literal(1))
            // the User object will be converted into a String and persisted into the VARCHAR column
            // "json"
            .value("json", literal(alice, session.getContext().getCodecRegistry()))
            .build();
    session.execute(stmt);

    // The JSON object can be a bound value if the statement is prepared
    // (subsequent calls to the prepare() method will return cached statement)
    PreparedStatement pst =
        session.prepare(
            insertInto("examples", "json_jackson_column")
                .value("id", bindMarker("id"))
                .value("json", bindMarker("json"))
                .build());
    session.execute(pst.bind().setInt("id", 2).set("json", bob, User.class));
  }
495212
@Override
	public synchronized RecordTag read(long tagId) throws DatabaseException {
    	SqlPreparedStatementWrapper psRead = null;
        try {
        	psRead = DbSQL.getSingleton().getPreparedStatement("tag.ps.read");
			psRead.getPs().setLong(1, tagId);
			
			try (ResultSet rs = psRead.getPs().executeQuery()) {
				return build(rs);
			}
		} catch (SQLException e) {
			throw new DatabaseException(e);
		} finally {
			DbSQL.getSingleton().releasePreparedStatement(psRead);
		}
	}
575832
@SafeVarargs
	public final void addInsert(Map<String, Object>... maps) throws SQLException {
		if (insertNps != null) {
			addAction(insertNps, insertKeysToColumns, maps);
			noOfInserts++;
		} else {
			throw new RuntimeException("No insert for importer: " + tableName);
		}
	}
411916
private void insert(String binding) {
		currentInput.insert(cursorPos, binding);
		cursorPos += binding.length();

		// reset view
		resetMainPart();
	}
1119700
@Override
  public <T> void insert(Object objectToSave) {
    if (null == objectToSave) {
      throw new InvalidJsonDbApiUsageException("Null Object cannot be inserted into DB");
    }
    Util.ensureNotRestricted(objectToSave);
    insert(objectToSave, Util.determineEntityCollectionName(objectToSave));
  }
1321034
@Override
	public synchronized RecordParam insert(String site, String type, String name, int used, String flags,
			String values) throws DatabaseException {
        try {
			psInsert.setString(1, site);
			psInsert.setString(2, type);
			psInsert.setString(3, name);
			psInsert.setInt(4, used);
			psInsert.setString(5, flags);
			psInsert.setString(6, values);
			psInsert.executeUpdate();
			
			long id;
			try (ResultSet rs = psGetIdLastInsert.executeQuery()) {
				rs.next();
				id = rs.getLong(1);
			}
			return read(id);
		} catch (SQLException e) {
			throw new DatabaseException(e);
		}
    }
660696
@Override
	public synchronized RecordScan insert(long sessionId, String scanName) throws DatabaseException {
    	SqlPreparedStatementWrapper psInsert = null;
        try {
        	psInsert = DbSQL.getSingleton().getPreparedStatement("scan.ps.insert");
			psInsert.getPs().setLong(1, sessionId);
			psInsert.getPs().setString(2, scanName);
			psInsert.getPs().executeUpdate();
			
			int id;
			try (ResultSet rs = psInsert.getLastInsertedId()) {
				rs.next();
				id = rs.getInt(1);
			}
			return read(id);
		} catch (SQLException e) {
			throw new DatabaseException(e);
		} finally {
			DbSQL.getSingleton().releasePreparedStatement(psInsert);
		}
    }