public static void simulateAutoIncrement(Connection connection, String tableName, String columnName) throws SQLException {
        String sequenceName = tableName + "_seq";
        String triggerName = tableName + "_id";
        connection.prepareStatement(
                "CREATE sequence " + sequenceName + " start with 1 increment by 1 nocycle"
        ).executeUpdate();
        // The oracle driver is getting confused by this statement, claiming we have to declare some in out parameter,
        // when we execute this as a prepared statement. Might be a config issue on our side.
        connection
                .createStatement()
                .execute(
                        "create or replace trigger " + triggerName +
                        "        before insert on " + tableName +
                        "        for each row " +
                        "        begin " +
                        "                :new." + columnName + " := " + sequenceName + ".nextval; " +
                        "        end;"
                );
    }
public static void simulateAutoIncrement(Connection connection, String tableName, String columnName) throws SQLException {
        String sequenceName = tableName + "_seq";
        String triggerName = tableName + "_id";
        connection.prepareStatement(
                "CREATE sequence " + sequenceName + " start with 1 increment by 1 nocycle"
        ).executeUpdate();
       
       
        connection
                .createStatement()
                .execute(
                        "create or replace trigger " + triggerName +
                        "        before insert on " + tableName +
                        "        for each row " +
                        "        begin " +
                        "                :new." + columnName + " := " + sequenceName + ".nextval; " +
                        "        end;"
                );
    }
public static void simulateautoincrement(connection connection, string tablename, string columnname) throws sqlexception { string sequencename = tablename + "_seq"; string triggername = tablename + "_id"; connection.preparestatement( "create sequence " + sequencename + " start with 1 increment by 1 nocycle" ).executeupdate(); connection .createstatement() .execute( "create or replace trigger " + triggername + " before insert on " + tablename + " for each row " + " begin " + " :new." + columnname + " := " + sequencename + ".nextval; " + " end;" ); }