snaker-core/src/main/java/org/snaker/engine/access/AbstractDBAccess.java
public void runScript() {
        String autoStr = ConfigHelper.getProperty("schema.auto");
        if(autoStr == null || !autoStr.equalsIgnoreCase("true")) {
            return;
        }
        Connection conn = null;
        try {
            conn = getConnection();
            if(JdbcHelper.isExec(conn)) {
                log.info("script has completed execution.skip this step");
                return;
            }
            String databaseType = JdbcHelper.getDatabaseType(conn);
            String schema = "db/core/schema-" + databaseType + ".sql";
            ScriptRunner runner = new ScriptRunner(conn, true);
            runner.runScript(schema);
        } catch (Exception e) {
            throw new SnakerException(e);
        } finally {
            try {
                JdbcHelper.close(conn);
            } catch (SQLException e) {
                //ignore
            }
        }
    }
public void runScript() {
        String autoStr = ConfigHelper.getProperty("schema.auto");
        if(autoStr == null || !autoStr.equalsIgnoreCase("true")) {
            return;
        }
        Connection conn = null;
        try {
            conn = getConnection();
            if(JdbcHelper.isExec(conn)) {
                log.info("script has completed execution.skip this step");
                return;
            }
            String databaseType = JdbcHelper.getDatabaseType(conn);
            String schema = "db/core/schema-" + databaseType + ".sql";
            ScriptRunner runner = new ScriptRunner(conn, true);
            runner.runScript(schema);
        } catch (Exception e) {
            throw new SnakerException(e);
        } finally {
            try {
                JdbcHelper.close(conn);
            } catch (SQLException e) {
                //ignore
            }
        }
    }
public void runScript ( ) { String autoStr = ConfigHelper . getProperty ( "schema.auto" ) ; if ( autoStr == null || ! autoStr . equalsIgnoreCase ( "true" ) ) { return ; } Connection conn = null ; try { conn = getConnection ( ) ; if ( JdbcHelper . isExec ( conn ) ) { log . info ( "script has completed execution.skip this step" ) ; return ; } String databaseType = JdbcHelper . getDatabaseType ( conn ) ; String schema = "db/core/schema-" + databaseType + ".sql" ; ScriptRunner runner = new ScriptRunner ( conn , true ) ; runner . runScript ( schema ) ; } catch ( Exception e ) { throw new SnakerException ( e ) ; } finally { try { JdbcHelper . close ( conn ) ; } catch ( SQLException e ) { //ignore } } }
运行脚本
运行脚本