-
Notifications
You must be signed in to change notification settings - Fork 8.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
version: 1.2.20 db: sqlserver 无法通过配置参数设置sqlserver的connectionTimeout(loginTimeout) 和 socketTimeout #5729
Comments
目前临时通过手动另外写一个配置DataSource的java类来设置 import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.pool.DruidDataSourceFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
@Configuration
public class DruidDatasourceConfig {
@Bean("dataSource")
public DataSource dataSource() throws Exception {
// :
// :
// :
DruidDataSource dataSource = (DruidDataSource) DruidDataSourceFactory.createDataSource(properties);
dataSource.setConnectTimeout(300000);
dataSource.setSocketTimeout(300000);
return dataSource;
}
} |
这两个参数已经埋了好多坑了。。JNDI,JDBC等。 |
根源是指定了默认值为10秒导致的坑,二实际场景中大家之前很少设置jdbc相关的timeout。 |
lizongbo
added a commit
to lizongbo/druid
that referenced
this issue
Feb 19, 2024
之前版本只能通过给datasoure配置属性来自定义超时实际,否则会走到默认值10秒逻辑,最新代码虽然也不区分jdbc类型,统一解析url和properties的设置了,但是为了存量项目无需修改任何配置就能平滑升级组件,因此还是去掉这个默认10秒的逻辑
lizongbo
added a commit
that referenced
this issue
Feb 19, 2024
之前版本只能通过给datasoure配置属性来自定义超时实际,否则会走到默认值10秒逻辑,最新代码虽然也不区分jdbc类型,统一解析url和properties的设置了,但是为了存量项目无需修改任何配置就能平滑升级组件,因此还是去掉这个默认10秒的逻辑
从 1.2.12 ~ 目前最新1.2.21 版本都有这问题, 只能退回 1.2.11 版本 |
请使用 1.2.22进行验证 |
所以我一直停留在1.2.11 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
如题
试过3种方法配置:
1: 直接配置
druid:
connectionTimeout: 300000
socketTimeout: 300000
2:jdbcurl中加参数
url: jdbc:sqlserver://****;loginTimeout=300000;socketTimeout=300000
3:配置connectionProperties属性
druid
connectionProperties: loginTimeout=300000;socketTimeout=300000
3种方式配置,最终通过druid创建出来的SqlServerConnection中,loginTimeout都是10,socketTimeout都是10000
The text was updated successfully, but these errors were encountered: