yu199195 commented on a change in pull request #2005:
URL: https://github.com/apache/incubator-shenyu/pull/2005#discussion_r701651743
##########
File path:
shenyu-admin/src/main/java/org/apache/shenyu/admin/spring/PostgreSqlLoader.java
##########
@@ -57,12 +66,37 @@ protected void init(final DataSourceProperties properties) {
// If jdbcUrl in the configuration file specifies the shenyu
database, It will be replaced by postgres,
// because postgresSql creates database scripts that require the
Postgres database to execute,
// otherwise the shenyu database will be disconnected when the
shenyu database does not exist
- String jdbcUrl = StringUtils.replace(properties.getUrl(),
"/shenyu", "/postgres");
- Connection connection = DriverManager.getConnection(jdbcUrl,
properties.getUsername(), properties.getPassword());
- super.execute(connection, dataBaseProperties.getDbScript());
+ String jdbcUrl = StringUtils.replace(properties.getUrl(),
"/shenyu", "/");
+ Connection conn = DriverManager.getConnection(jdbcUrl,
properties.getUsername(), properties.getPassword());
+ ScriptRunner runner = new ScriptRunner(conn);
+ // doesn't print logger
+ runner.setLogWriter(null);
+ // doesn't print error
+ runner.setErrorLogWriter(null);
+ runner.setAutoCommit(false);
+ runner.setSendFullScript(true);
+ Resources.setCharset(StandardCharsets.UTF_8);
+ Reader read = fillInfoToSqlFile(properties.getUsername(),
properties.getPassword());
+ runner.runScript(read);
+ conn.commit();
+ runner.closeConnection();
+ conn.close();
Review comment:
conn.close in finally
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]