You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.2.8以上版本,当协议是jdbc:mysql:loadbalance://时,查询超过10秒就会报错.
经过验证发现1.2.8以上的版本中新增了一个socketTimeout属性,而这个属性在1.2.8以上的版本中无论是connectionProperties中设置还是直接在url中设置都不生效.只能在获取到数据源对象后,手动设置一下才可以.
如果我把协议换成jdbc:mysql://时,则1.2.8以上在url中加上socketTimeout也可以支持.但是这样就不支持集群了,只能固定一个数据库地址查询.
如果把druid换成1.2.8版本,则不需要配置socketTimeout这些属性就不会报错,推测1.2.8及以下的版本是读取的maxWait这个属性.
`com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet successfully received from the server was 10,090 milliseconds ago. The last packet sent successfully to the server was 10,090 milliseconds ago.
at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:974)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:1024)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.mysql.cj.jdbc.ha.MultiHostConnectionProxy$JdbcInterfaceProxy.invoke(MultiHostConnectionProxy.java:105)
at com.sun.proxy.$Proxy88.executeQuery(Unknown Source)
at com.alibaba.druid.pool.DruidPooledPreparedStatement.executeQuery(DruidPooledPreparedStatement.java:213)`
Activity
lizongbo commentedon Sep 30, 2023
核实是initFromUrlOrProperties方法,没有判断loadbalance格式的url,没有识别到参数。
我来加一下适配
if (jdbcUrl.startsWith("jdbc:mysql://") || jdbcUrl.startsWith("jdbc:mysql:loadbalance://")) {针对mysql loadbalance格式的url,加上connectTimeout等属性的识别支持 alibaba#5396
针对mysql loadbalance格式的url,加上connectTimeout等属性的识别支持 #5396 (#5454)
kimmking commentedon Oct 5, 2023
请使用最新版本。
lizhuangs commentedon Oct 7, 2023
还没发布呃
lizongbo commentedon Oct 8, 2023
1.2.20已经发布,请更新
lizhuangs commentedon Oct 9, 2023
测试可以了,感谢。
针对mysql loadbalance格式的url,加上connectTimeout等属性的识别支持 alibaba#5396 (alib…
针对mysql loadbalance格式的url,加上connectTimeout等属性的识别支持 alibaba#5396 (alib…