package org.dbsyncer.connector.database;
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.SQLWarningException;
import org.springframework.jdbc.UncategorizedSQLException;
import org.springframework.jdbc.core.*;
import org.springframework.jdbc.datasource.ConnectionProxy;
import org.springframework.jdbc.datasource.DataSourceUtils;
import org.springframework.jdbc.support.JdbcAccessor;
import org.springframework.jdbc.support.JdbcUtils;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.jdbc.support.rowset.SqlRowSet;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.LinkedCaseInsensitiveMap;
import org.springframework.util.StringUtils;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.sql.*;
import java.util.*;
public class DatabaseTemplate extends JdbcAccessor implements JdbcOperations {
private final Logger logger = LoggerFactory.getLogger(getClass());
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;
private Connection connection;
public DatabaseTemplate(Connection connection) {
this.connection = connection;
}
/**
* 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 a 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
* that might return a large number of matches).
* <p>Default is -1, indicating to use the JDBC driver's default configuration
* (i.e. to not pass a specific max rows setting on to the driver).
* <p>Note: As of 4.3, negative values other than -1 will get passed on to the
* driver, in sync with {@link #setFetchSize}'s support for special MySQL values.
*
* @see java.sql.Statement#setMaxRows
*/
public void setMaxRows(int maxRows) {
this.maxRows = maxRows;
}
/**
* Return the maximum number of rows specified for this JdbcTemplate.
*/
public int getMaxRows() {
return this.maxRows;
}
/**
* Set the query timeout for statements that this JdbcTemplate executes.
* <p>Default is -1, indicating to use the JDBC driver's default
* (i.e. to not pass a specific query timeout setting on the driver).
* <p>Note: Any timeout specified here will be overridden by the remaining
* transaction timeout when executing within a transaction that has a
* timeout specified at the transaction level.
*
* @see java.sql.Statement#setQueryTimeout
*/
public void setQueryTimeout(int queryTimeout) {
this.queryTimeout = queryTimeout;
}
/**
* Return the query timeout for statements that this JdbcTemplate executes.
*/
public int getQueryTimeout() {
return this.queryTimeout;
}
/**
* Set whether results processing should be skipped. Can be used to optimize callable
* statement processing when we know that no results are being passed back - the processing
* of out parameter will still take place. This can be used to avoid a bug in some older
* Oracle JDBC drivers like 10.1.0.2.
*/
public void setSkipResultsProcessing(boolean skipResultsProcessing) {
this.skipResultsProcessing = skipResultsProcessing;
}
/**
* Return whether results processing should be skipped.
*/
public boolean isSkipResultsProcessing() {
return this.skipResultsProcessing;
}
/**
* Set whether undeclared results should be skipped.
*/
public void setSkipUndeclaredResults(boolean skipUndeclaredResults) {
this.skipUndeclaredResults = skipUndeclaredResults;
}
/**
* Return whether undeclared results should be skipped.
*/
public boolean isSkipUndeclaredResults() {
return this.skipUndeclaredResults;
}
/**
* Set whether execution of a CallableStatement will return the results in a Map
* that uses case insensitive names for the parameters.
*/
public void setResultsMapCaseInsensitive(boolean resultsMapCaseInsensitive) {
this.resultsMapCaseInsensitive = resultsMapCaseInsensitive;
}
/**
* Return whether execution
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
DBSyncer(简称dbs)是一款开源的数据同步中间件,提供MySQL、Oracle、SqlServer、PostgreSQL、Elasticsearch(ES)、Kafka、File、SQL等同步场景。支持上传插件自定义同步转换业务,提供监控全量和增量数据统计图、应用性能预警等。组合驱动,自定义库同步到库组合,关系型数据库与非关系型之间组合,任意搭配表同步映射关系。实时监控,驱动全量或增量实时同步运行状态、结果、同步日志和系统日志。开发插件,自定义转化同步逻辑
资源推荐
资源详情
资源评论
收起资源包目录
dbsyncer-master.zip (730个子文件)
jmxremote.access 4KB
startup.bat 2KB
version.cmd 474B
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
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
plugin.html 9KB
edit.html 7KB
editFilter.html 5KB
addDqlPostgreSQL.html 5KB
edit.html 5KB
addFile.html 5KB
editTable.html 4KB
editConvert.html 4KB
addDqlSqlServer.html 4KB
addDqlOracle.html 4KB
add.html 4KB
add.html 4KB
config.html 4KB
addPostgreSQL.html 3KB
index.html 3KB
addDqlMysql.html 3KB
edit.html 3KB
editIncrement.html 3KB
save.html 3KB
add.html 3KB
addRedis.html 3KB
addElasticsearch.html 2KB
user.html 2KB
editIncrementQuartz.html 2KB
retry.html 2KB
nav.html 2KB
addSqlServer.html 2KB
addOracle.html 2KB
addMysql.html 2KB
共 730 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
m0_72731342
- 粉丝: 2
- 资源: 1832
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于matlab实现电磁优化计算功能,进行线型规划优化电磁设计.rar
- 基于matlab实现带精英策略的非支配排序遗传算法matlab 源码.rar
- 基于matlab实现差分进化算法,最新的用于替代遗传算法,是以后的主要发展方法.rar
- VSCode配置c/c++环境教程.md
- 基于matlab实现标准合作型协同进化遗传算法matlab源程序
- 七下人教.zip
- 基于matlab实现本份代码能对图像进行gabor滤波处理,结合指纹方向图以及指纹沟壑频率特性,对指纹图像进行增强.rar
- 基于matlab实现RBM神经网络实现了手写数字体识别的GUI程序.rar
- 基于matlab实现蝙蝠算法优化相关向量机建模对数据进行建模和预测.rar
- 基于matlab实现编写的禁忌搜索算法,解决了TSP问题,对初学者有重要的参考价值.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功