Tony CHEMIT pushed to branch develop at ultreiaio / ird-t3
Commits:
-
d7bdbdc7
by Tony CHEMIT at 2017-04-10T15:12:36+02:00
1 changed file:
Changes:
| ... | ... | @@ -74,20 +74,30 @@ public class T3JdbcHelper extends JdbcHelper { |
| 74 | 74 |
try (Connection connection = openConnection()) {
|
| 75 | 75 |
try (Statement preparedStatement = connection.createStatement()) {
|
| 76 | 76 |
|
| 77 |
- int currentBuffer = 0;
|
|
| 78 |
- StringBuilder currentStatement = new StringBuilder();
|
|
| 77 |
+ int statementCount = 0;
|
|
| 78 |
+ StringBuilder currentStatement = null;
|
|
| 79 | 79 |
for (String sqlStatement : new SqlFileReader(reader)) {
|
| 80 | 80 |
if (sqlStatement.startsWith("--")) {
|
| 81 | 81 |
continue;
|
| 82 | 82 |
}
|
| 83 |
- currentStatement.append("\n").append(sqlStatement);
|
|
| 84 | 83 |
if (sqlStatement.trim().endsWith(";")) {
|
| 85 |
- preparedStatement.addBatch(currentStatement.toString());
|
|
| 86 |
- currentBuffer++;
|
|
| 87 |
- currentStatement = new StringBuilder();
|
|
| 84 |
+ if (currentStatement == null) {
|
|
| 85 |
+ preparedStatement.addBatch(sqlStatement);
|
|
| 86 |
+ } else {
|
|
| 87 |
+ currentStatement.append("\n").append(sqlStatement);
|
|
| 88 |
+ preparedStatement.addBatch(currentStatement.toString());
|
|
| 89 |
+ currentStatement = null;
|
|
| 90 |
+ }
|
|
| 91 |
+ statementCount++;
|
|
| 92 |
+ } else {
|
|
| 93 |
+ if (currentStatement == null) {
|
|
| 94 |
+ currentStatement = new StringBuilder(sqlStatement);
|
|
| 95 |
+ } else {
|
|
| 96 |
+ currentStatement.append("\n").append(sqlStatement);
|
|
| 97 |
+ }
|
|
| 88 | 98 |
}
|
| 89 | 99 |
|
| 90 |
- if (currentBuffer % BUZZER_SIZE == 0) {
|
|
| 100 |
+ if (statementCount % BUZZER_SIZE == 0) {
|
|
| 91 | 101 |
preparedStatement.executeBatch();
|
| 92 | 102 |
preparedStatement.clearBatch();
|
| 93 | 103 |
}
|