package org.dbsyncer.connector.database;
import org.dbsyncer.connector.ConnectorException;
import org.dbsyncer.connector.database.ds.SimpleConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.dao.support.DataAccessUtils;
import org.springframework.jdbc.InvalidResultSetAccessException;
import org.springframework.jdbc.SQLWarningException;
import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.jdbc.core.ArgumentPreparedStatementSetter;
import org.springframework.jdbc.core.ArgumentTypePreparedStatementSetter;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.CallableStatementCallback;
import org.springframework.jdbc.core.CallableStatementCreator;
import org.springframework.jdbc.core.ColumnMapRowMapper;
import org.springframework.jdbc.core.ConnectionCallback;
import org.springframework.jdbc.core.InterruptibleBatchPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcOperations;
import org.springframework.jdbc.core.ParameterDisposer;
import org.springframework.jdbc.core.ParameterizedPreparedStatementSetter;
import org.springframework.jdbc.core.PreparedStatementCallback;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.core.PreparedStatementSetter;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.ResultSetSupportingSqlParameter;
import org.springframework.jdbc.core.RowCallbackHandler;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.jdbc.core.RowMapperResultSetExtractor;
import org.springframework.jdbc.core.SingleColumnRowMapper;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.SqlParameterValue;
import org.springframework.jdbc.core.SqlProvider;
import org.springframework.jdbc.core.SqlReturnResultSet;
import org.springframework.jdbc.core.SqlReturnType;
import org.springframework.jdbc.core.SqlReturnUpdateCount;
import org.springframework.jdbc.core.SqlRowSetResultSetExtractor;
import org.springframework.jdbc.core.SqlTypeValue;
import org.springframework.jdbc.core.StatementCallback;
import org.springframework.jdbc.core.StatementCreatorUtils;
import org.springframework.jdbc.datasource.ConnectionProxy;
import org.springframework.jdbc.support.JdbcUtils;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.jdbc.support.SQLExceptionTranslator;
import org.springframework.jdbc.support.SQLStateSQLExceptionTranslator;
import org.springframework.jdbc.support.rowset.SqlRowSet;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.util.LinkedCaseInsensitiveMap;
import org.springframework.util.StringUtils;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.BatchUpdateException;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Spliterator;
import java.util.function.Consumer;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
public class DatabaseTemplate implements JdbcOperations {
private final Logger logger = LoggerFactory.getLogger(getClass());
private SimpleConnection connection;
public DatabaseTemplate(SimpleConnection connection) {
this.connection = connection;
}
public SimpleConnection getSimpleConnection() {
return connection;
}
private final SQLExceptionTranslator exceptionTranslator = new SQLStateSQLExceptionTranslator();
private static final String RETURN_RESULT_SET_PREFIX = "#result-set-";
private static final String RETURN_UPDATE_COUNT_PREFIX = "#update-count-";
/**
* If this variable is false, we will throw exceptions on SQL warnings.
*/
private boolean ignoreWarnings = true;
/**
* If this variable is set to a non-negative value, it will be used for setting the
* fetchSize property on statements used for query processing.
*/
private int fetchSize = -1;
/**
* If this variable is set to a non-negative value, it will be used for setting the
* maxRows property on statements used for query processing.
*/
private int maxRows = -1;
/**
* If this variable is set to a non-negative value, it will be used for setting the
* queryTimeout property on statements used for query processing.
*/
private int queryTimeout = -1;
/**
* If this variable is set to true, then all results checking will be bypassed for any
* callable statement processing. This can be used to avoid a bug in some older Oracle
* JDBC drivers like 10.1.0.2.
*/
private boolean skipResultsProcessing = false;
/**
* If this variable is set to true then all results from a stored procedure call
* that don't have a corresponding SqlOutParameter declaration will be bypassed.
* All other results processing will be take place unless the variable
* {@code skipResultsProcessing} is set to {@code true}.
*/
private boolean skipUndeclaredResults = false;
/**
* If this variable is set to true then execution of a CallableStatement will return
* the results in a Map that uses case insensitive names for the parameters.
*/
private boolean resultsMapCaseInsensitive = false;
/**
* Set whether or not we want to ignore SQLWarnings.
* <p>Default is "true", swallowing and logging all warnings. Switch this flag
* to "false" to make the JdbcTemplate throw an SQLWarningException instead.
*
* @see java.sql.SQLWarning
* @see org.springframework.jdbc.SQLWarningException
* @see #handleWarnings
*/
public void setIgnoreWarnings(boolean ignoreWarnings) {
this.ignoreWarnings = ignoreWarnings;
}
/**
* Return whether or not we ignore SQLWarnings.
*/
public boolean isIgnoreWarnings() {
return this.ignoreWarnings;
}
/**
* Set the fetch size for this JdbcTemplate. This is important for processing large
* result sets: Setting this higher than the default value will increase processing
* speed at the cost of memory consumption; setting this lower can avoid transferring
* row data that will never be read by the application.
* <p>Default is -1, indicating to use the JDBC driver's default configuration
* (i.e. to not pass a specific fetch size setting on to the driver).
* <p>Note: As of 4.3, negative values other than -1 will get passed on to the
* driver, since e.g. MySQL supports special behavior for {@code Integer.MIN_VALUE}.
*
* @see java.sql.Statement#setFetchSize
*/
public void setFetchSize(int fetchSize) {
this.fetchSize = fetchSize;
}
/**
* Return the fetch size specified for this JdbcTemplate.
*/
public int getFetchSize() {
return this.fetchSize;
}
/**
* Set the maximum number of rows for this JdbcTemplate. This is important for
* processing subsets of large result sets, avoiding to read and hold the entire
* result set in the database or in the JDBC driver if we're never interested in
* the entire result in the first place (for example, when performing searches
*
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
DBSyncer(简称dbs)是一款开源的数据同步中间件,提供MySQL、Oracle、SqlServer、PostgreSQL、Elasticsearch(ES)、Kafka、File、SQL等同步场景。支持上传插件自定义同步转换业务,提供监控全量和增量数据统计图、应用性能预警等。
资源推荐
资源详情
资源评论
收起资源包目录
一款开源的数据同步中间件提供MySQL、Oracle、SqlServer、Postgre,File,kafka,SQL等同步场景 (737个子文件)
jmxremote.access 4KB
startup.bat 2KB
version.cmd 387B
build.cmd 248B
bootstrap.min.css 115KB
font-awesome.min.css 30KB
_all.css 20KB
_all.css 14KB
_all.css 14KB
_all.css 12KB
bootstrap-select.min.css 10KB
fileinput.min.css 9KB
bootstrap-checkbox.css 7KB
bootstrap-switch.min.css 6KB
login.css 3KB
purple.css 2KB
yellow.css 2KB
orange.css 2KB
green.css 2KB
pink.css 2KB
blue.css 2KB
grey.css 2KB
aero.css 2KB
red.css 2KB
line.css 2KB
bootstrap-dialog.min.css 2KB
index.css 2KB
all.css 2KB
purple.css 2KB
orange.css 2KB
yellow.css 2KB
purple.css 2KB
orange.css 2KB
yellow.css 2KB
green.css 2KB
green.css 1KB
pink.css 1KB
blue.css 1KB
grey.css 1KB
aero.css 1KB
pink.css 1KB
blue.css 1KB
grey.css 1KB
aero.css 1KB
red.css 1KB
red.css 1KB
minimal.css 1KB
polaris.css 1KB
square.css 1KB
purple.css 1KB
orange.css 1KB
yellow.css 1KB
green.css 1KB
pink.css 1KB
blue.css 1KB
grey.css 1KB
aero.css 1KB
futurico.css 1KB
red.css 1KB
flat.css 1KB
common.css 1KB
bootstrap-tagsinput.min.css 1KB
loading-plus.css 396B
fontawesome-webfont.eot 162KB
spring.factories 168B
loading-sm.gif 3KB
loading.gif 847B
.gitignore 122B
index.html 15KB
addKafka.html 14KB
monitor.html 12KB
editTableGroup.html 10KB
addSQL.html 10KB
plugin.html 9KB
edit.html 7KB
editFilter.html 5KB
edit.html 5KB
addFile.html 5KB
editTable.html 4KB
editConvert.html 4KB
addDqlPostgreSQL.html 4KB
add.html 4KB
add.html 4KB
index.html 4KB
config.html 4KB
addPostgreSQL.html 3KB
edit.html 3KB
editIncrement.html 3KB
save.html 3KB
add.html 3KB
user.html 3KB
addDqlSqlServer.html 3KB
addRedis.html 3KB
editIncrementQuartz.html 2KB
addDqlOracle.html 2KB
retry.html 2KB
nav.html 2KB
addDqlMysql.html 2KB
addSqlServer.html 2KB
addOracle.html 2KB
共 737 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
- haokan_Jia2024-06-03资源不错,对我启发很大,获得了新的灵感,受益匪浅。
- 柔弱弱2024-07-24发现一个宝藏资源,资源有很高的参考价值,赶紧学起来~
Java程序员-张凯
- 粉丝: 1w+
- 资源: 6933
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功