提交 2d1ad489 编写于 作者: T terrymanu

refactor

上级 36d8bce3
......@@ -152,11 +152,6 @@ public final class ShardingPreparedStatement extends AbstractPreparedStatementAd
});
}
@Override
public void clearRoutedStatements() throws SQLException {
getRoutedPreparedStatements().clear();
}
private void routeIfNeed() throws SQLException {
if (!cachedRoutedPreparedStatements.isEmpty()) {
return;
......
......@@ -187,9 +187,4 @@ public class ShardingStatement extends AbstractStatementAdapter {
public Collection<? extends Statement> getRoutedStatements() throws SQLException {
return cachedRoutedStatements.values();
}
@Override
public void clearRoutedStatements() throws SQLException {
cachedRoutedStatements.clear();
}
}
......@@ -17,15 +17,14 @@
package com.dangdang.ddframe.rdb.sharding.jdbc.adapter;
import com.dangdang.ddframe.rdb.sharding.jdbc.unsupported.AbstractUnsupportedOperationStatement;
import lombok.RequiredArgsConstructor;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.Collection;
import com.dangdang.ddframe.rdb.sharding.jdbc.unsupported.AbstractUnsupportedOperationStatement;
import lombok.RequiredArgsConstructor;
/**
* 静态语句对象适配类.
*
......@@ -157,11 +156,4 @@ public abstract class AbstractStatementAdapter extends AbstractUnsupportedOperat
* @throws SQLException
*/
protected abstract Collection<? extends Statement> getRoutedStatements() throws SQLException;
/**
*  清除路由的静态语句对象集合.
*
* @throws SQLException
*/
public abstract void clearRoutedStatements() throws SQLException;
}
......@@ -191,7 +191,7 @@ public final class ShardingPreparedStatementTest extends AbstractShardingDataBas
}
@Test
public void assertBatch() throws SQLException {
public void assertAddBatch() throws SQLException {
String sql = "INSERT INTO `t_order`(`order_id`, `user_id`, `status`) VALUES (?,?,?)";
try (
Connection connection = shardingDataSource.getConnection();
......@@ -210,4 +210,19 @@ public final class ShardingPreparedStatementTest extends AbstractShardingDataBas
}
}
}
@Test(expected = IllegalStateException.class)
public void assertClearBatch() throws SQLException {
String sql = "INSERT INTO `t_order`(`order_id`, `user_id`, `status`) VALUES (?,?,?)";
try (
Connection connection = shardingDataSource.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
preparedStatement.setInt(1, 3101);
preparedStatement.setInt(2, 11);
preparedStatement.setString(3, "BATCH");
preparedStatement.addBatch();
preparedStatement.clearBatch();
preparedStatement.executeBatch();
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册