DataJdbcSource
This commit is contained in:
@@ -450,10 +450,14 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
|||||||
try {
|
try {
|
||||||
//执行一遍创建分表操作
|
//执行一遍创建分表操作
|
||||||
Statement stmt = conn.createUpdateStatement();
|
Statement stmt = conn.createUpdateStatement();
|
||||||
for (String copySql : tableCopys) {
|
if (tableCopys.size() == 1) {
|
||||||
stmt.addBatch(copySql);
|
stmt.execute(tableCopys.get(0));
|
||||||
|
} else {
|
||||||
|
for (String copySql : tableCopys) {
|
||||||
|
stmt.addBatch(copySql);
|
||||||
|
}
|
||||||
|
stmt.executeBatch();
|
||||||
}
|
}
|
||||||
stmt.executeBatch();
|
|
||||||
conn.offerUpdateStatement(stmt);
|
conn.offerUpdateStatement(stmt);
|
||||||
} catch (SQLException sqle) { //多进程并发时可能会出现重复建表
|
} catch (SQLException sqle) { //多进程并发时可能会出现重复建表
|
||||||
if (isTableNotExist(info, sqle.getSQLState())) {
|
if (isTableNotExist(info, sqle.getSQLState())) {
|
||||||
@@ -473,10 +477,14 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
|||||||
conn.offerUpdateStatement(stmt);
|
conn.offerUpdateStatement(stmt);
|
||||||
//再执行一遍创建分表操作
|
//再执行一遍创建分表操作
|
||||||
stmt = conn.createUpdateStatement();
|
stmt = conn.createUpdateStatement();
|
||||||
for (String copySql : tableCopys) {
|
if (tableCopys.size() == 1) {
|
||||||
stmt.addBatch(copySql);
|
stmt.execute(tableCopys.get(0));
|
||||||
|
} else {
|
||||||
|
for (String copySql : tableCopys) {
|
||||||
|
stmt.addBatch(copySql);
|
||||||
|
}
|
||||||
|
stmt.executeBatch();
|
||||||
}
|
}
|
||||||
stmt.executeBatch();
|
|
||||||
conn.offerUpdateStatement(stmt);
|
conn.offerUpdateStatement(stmt);
|
||||||
}
|
}
|
||||||
} else { //需要先建库
|
} else { //需要先建库
|
||||||
@@ -496,10 +504,14 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
|||||||
try {
|
try {
|
||||||
//再执行一遍创建分表操作
|
//再执行一遍创建分表操作
|
||||||
stmt = conn.createUpdateStatement();
|
stmt = conn.createUpdateStatement();
|
||||||
for (String copySql : tableCopys) {
|
if (tableCopys.size() == 1) {
|
||||||
stmt.addBatch(copySql);
|
stmt.execute(tableCopys.get(0));
|
||||||
|
} else {
|
||||||
|
for (String copySql : tableCopys) {
|
||||||
|
stmt.addBatch(copySql);
|
||||||
|
}
|
||||||
|
stmt.executeBatch();
|
||||||
}
|
}
|
||||||
stmt.executeBatch();
|
|
||||||
conn.offerUpdateStatement(stmt);
|
conn.offerUpdateStatement(stmt);
|
||||||
} catch (SQLException sqle2) {
|
} catch (SQLException sqle2) {
|
||||||
if (isTableNotExist(info, sqle2.getSQLState())) {
|
if (isTableNotExist(info, sqle2.getSQLState())) {
|
||||||
@@ -517,10 +529,14 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
|||||||
conn.offerUpdateStatement(stmt);
|
conn.offerUpdateStatement(stmt);
|
||||||
//再执行一遍创建分表操作
|
//再执行一遍创建分表操作
|
||||||
stmt = conn.createUpdateStatement();
|
stmt = conn.createUpdateStatement();
|
||||||
for (String copySql : tableCopys) {
|
if (tableCopys.size() == 1) {
|
||||||
stmt.addBatch(copySql);
|
stmt.execute(tableCopys.get(0));
|
||||||
|
} else {
|
||||||
|
for (String copySql : tableCopys) {
|
||||||
|
stmt.addBatch(copySql);
|
||||||
|
}
|
||||||
|
stmt.executeBatch();
|
||||||
}
|
}
|
||||||
stmt.executeBatch();
|
|
||||||
conn.offerUpdateStatement(stmt);
|
conn.offerUpdateStatement(stmt);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -528,6 +544,8 @@ public class DataJdbcSource extends AbstractDataSqlSource {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
logger.log(Level.INFO, "executeBatch error, sqls: " + tableCopys, sqle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user