开发者社区> 问答> 正文

获得连接异常

感觉是无法获得随机数的问题。

org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.lang.IllegalArgumentException: Failed to decrypt. at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:245) at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:373) at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:427) at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:276) at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655) at cn.vpclub.promotion.coupon.provider.taskservice.RemoveEndCouponTaskBean$$EnhancerBySpringCGLIB$$b8f1e894.removeEndCouponTerm() 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 org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.IllegalArgumentException: Failed to decrypt. at com.alibaba.druid.filter.config.ConfigFilter.decrypt(ConfigFilter.java:211) at com.alibaba.druid.filter.config.ConfigFilter.init(ConfigFilter.java:123) at com.alibaba.druid.pool.DruidDataSource.init(DruidDataSource.java:548) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:927) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:923) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:100) at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:204) ... 20 common frames omitted Caused by: javax.crypto.BadPaddingException: Message is larger than modulus at sun.security.rsa.RSACore.parseMsg(RSACore.java:214) at sun.security.rsa.RSACore.crypt(RSACore.java:133) at sun.security.rsa.RSACore.rsa(RSACore.java:100) at com.sun.crypto.provider.RSACipher.doFinal(RSACipher.java:355) at com.sun.crypto.provider.RSACipher.engineDoFinal(RSACipher.java:389) at javax.crypto.Cipher.doFinal(Cipher.java:2165) at com.alibaba.druid.filter.config.ConfigTools.decrypt(ConfigTools.java:147) at com.alibaba.druid.filter.config.ConfigFilter.decrypt(ConfigFilter.java:203)

`### Cause: java.lang.NullPointerException at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:79) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:447) at com.sun.proxy.$Proxy56.update(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.update(SqlSessionTemplate.java:295) at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:59) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53) at com.sun.proxy.$Proxy66.upCouponStatusFor(Unknown Source) at cn.vpclub.promotion.coupon.provider.service.CouponActivityMemoryServiceImpl.auditToFor(CouponActivityMemoryServiceImpl.java:471) at cn.vpclub.promotion.coupon.provider.taskservice.OverdueCouponTaskBean.overdueCouponTaskBean(OverdueCouponTaskBean.java:39) 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 org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) Caused by: org.apache.ibatis.exceptions.PersistenceException:

Error updating database. Cause: java.lang.NullPointerException Cause: java.lang.NullPointerException

at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:200) 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 org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:434) ... 20 common frames omitted

Caused by: java.lang.NullPointerException: null at com.alibaba.druid.pool.DruidDataSource.getConnectionInternal(DruidDataSource.java:1118) at com.alibaba.druid.pool.DruidDataSource.getConnectionDirect(DruidDataSource.java:953) at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4544) at com.alibaba.druid.filter.FilterAdapter.dataSource_getConnection(FilterAdapter.java:2723) at com.alibaba.druid.filter.FilterChainImpl.dataSource_connect(FilterChainImpl.java:4540) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:931) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:923) at com.alibaba.druid.pool.DruidDataSource.getConnection(DruidDataSource.java:100) at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111) at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77) at org.mybatis.spring.transaction.SpringManagedTransaction.openConnection(SpringManagedTransaction.java:84) at org.mybatis.spring.transaction.SpringManagedTransaction.getConnection(SpringManagedTransaction.java:70) at org.apache.ibatis.executor.BaseExecutor.getConnection(BaseExecutor.java:337) at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:84) at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:49) at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117) at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76) 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 org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) at com.sun.proxy.$Proxy94.update(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:198) `

原提问者GitHub用户githublaohu

展开
收起
山海行 2023-07-05 21:05:35 52 0
3 条回答
写回答
取消 提交回答
  • 您的异常信息显示了两个错误:Could not open JDBC Connection for transactionFailed to decrypt。这些错误可能是由于数据库连接配置出错和解密失败导致的。

    首先,检查数据库连接配置是否正确。确保数据库连接的URL、用户名和密码等配置项正确无误。如果您对加密算法进行了定制,还需要确保解密密钥和算法的正确性。

    其次,检查解密过程中是否存在问题。请确认使用的解密算法、密钥以及解密过程中的参数是否正确。如果解密失败,可以尝试使用正确的解密算法和密钥重新解密。

    如果以上方法都不能解决问题,建议您查看应用程序的源码和相关配置文件,确认连接池和加密解密的实现逻辑。另外,也可以通过调试和日志记录来定位具体的问题所在。

    2023-07-30 15:06:41
    赞同 展开评论 打赏
  • 北京阿里云ACE会长

    在您的异常信息中,出现了Failed to decrypt的错误消息,这通常意味着您正在使用加密的数据库连接信息,但是应用程序无法正确地解密它们。

    可能的原因是您的应用程序使用了加密算法对数据库连接信息进行了加密,并将它们存储在配置文件或其他地方。但是,在运行时,应用程序无法正确地解密这些信息,从而导致连接数据库时出现问题。

    可以检查以下几个方面:

    确认加密算法和密钥是否正确
    如果您使用了加密算法对数据库连接信息进行了加密,需要确保在解密时使用了正确的算法和密钥。如果算法或密钥不正确,就无法正确解密连接信息,从而导致连接数据库时出现问题。

    确认密文和解密方法是否匹配
    如果您使用了对称加密算法对数据库连接信息进行了加密,需要确保加密和解密时使用的方法和参数是匹配的。例如,如果您在加密时使用了AES/CBC/PKCS5Padding算法和AES密钥,那么在解密时也需要使用相同的算法和密钥。

    确认加密和解密的代码是否正确
    如果您使用了自定义的加密和解密代码,需要确保代码正确性。例如,在加密时需要使用正确的加密算法、密钥和参数,并将密文以正确的格式存储。在解密时需要使用正确的解密算法、密钥和参数,并正确处理异常情况。

    2023-07-30 13:02:22
    赞同 展开评论 打赏
  • 是随机因子。造成 druid 解密错误。

    原回答者GitHub用户githublaohu

    2023-07-06 11:53:32
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载