1. ホーム
  2. マイスル

CannotGetJdbcConnectionException: JDBC 接続の取得に失敗しました。

2022-03-17 16:06:07
<パス

CannotGetJdbcConnectionException: ネストされた例外は org.apache.commons.dbcp.JDBC 接続の取得に失敗しました。SQLNestedException です。PoolableConnectionFactory を作成できない (Unknown system variable 'query_cache_size')

クラウドプロジェクトで、mysql 8.0.13に接続するとエラーが発生します。



ドライバも更新しました。



以下は、一部の  package com.yinbodotcc.Transaction; /*  * The first thing to note is that the transaction mechanism in this example is really cobbled together.  /* * The purpose is to show how fine-grained the transaction control is in your own programming code.  */ import javax.sql.*; import java.util.*; import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.transaction.TransactionStatus; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.transaction.support.TransactionTemplate; import org.springframework.transaction.support.TransactionCallbackWithoutResult; import org.springframework.dao.DataAccessException;   public class UserDao implements IUserDao {  private JdbcTemplate jdbcTemplate;  private DataSourceTransactionManager dataSourceTransactionManager;  private DefaultTransactionDefinition defaultTransactionDefinition;    public void setDs(DataSource ds)  {   jdbcTemplate = new JdbcTemplate(ds);   defaultTransactionDefinition =new DefaultTransactionDefinition();   defaultTransactionDefinition.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);   dataSourceTransactionManager=new DataSourceTransactionManager(ds);     }    //TransactionManager implements the transaction mechanism  public void insert(User user)  {   String name=user.getName();   int age=user.getAge();   TransactionStatus ts=dataSourceTransactionManager.getTransaction(defaultTransactionDefinition);   String sql1="insert into user(name,age) values(? ,?) ";   try   {    jdbcTemplate.update(sql1, new Object[]{name,age});    jdbcTemplate.update(sql1, new Object[]{name,"hello"});//intentionally written wrong, type mismatch   }   catch(Exception e)   {    dataSourceTransactionManager.rollback(ts);    e.printStackTrace();   }   dataSourceTransactionManager.commit(ts);  }   / /TransactionTemplate embodies the transaction processing mechanism  public User find(int id)  {   final int tempId=id;   final User user=new User();   TransactionTemplate tt=new TransactionTemplate(dataSourceTransactionManager);   tt.execute(new TransactionCallbackWithoutResult(){    public void doInTransactionWithoutResult(TransactionStatus status)    {     try     {      /*       * Although there will be a transaction rollback here, the value taken out will be owned by the user once it is assigned to the user       */      String sql="select * from user where id=? ";      Map m=jdbcTemplate.queryForMap(sql,new Object[]{tempId});      int id=(Integer)m.get("id");      String name=(String)m.get("name");      int age=(Integer)m.get("age");      user.setAge(age);      user.setId(id);      user.setName(name);                sql="insert into user(id,name,age) values(78,'dfx','hello')";      jdbcTemplate.execute(sql);           }     catch(DataAccessException e)     {      status.setRollbackOnly();      e.printStackTrace();     }    }   });            return user;  }   } .

これは、URLです。

// An highlighted block
db:
  num: 1
  user: ${MYSQL-USER:root}
  password: ${MYSQL-PWD:root}
  url:
    0: jdbc:mysql://${MYSQL-HOST:127.0.0.1}:${MYSQL-PORT:3306}/${MYSQL-DB:cloudx_config}?characterEncoding=utf8& zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false& serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true&allowPublicKeyRetrieval=true



// An highlighted block
2020-03-11 13:32:26.004 INFO 10896 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure. ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure. ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$9fc1c6ae] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-11 13:32:26.057 INFO 10896 --- [ main] c.l.StartingSpringApplicationRunListener : Nacos Log files: C:\Users\DELL\nacos/logs/
2020-03-11 13:32:26.057 INFO 10896 --- [ main] c.l.StartingSpringApplicationRunListener : Nacos Conf files: C:\Users\DELL\nacos/conf/
2020-03-11 13:32:26.058 INFO 10896 --- [ main] c.l.StartingSpringApplicationRunListener : Nacos Data files: C:\Users\DELL\nacos/data/
2020-03-11 13:32:26.058 INFO 10896 --- [ main] c.l.StartingSpringApplicationRunListener : Nacos started successfully in stand alone mode.

         ,--.
       ,--.' |--.
   ,--,: : | Nacos 
,--.' `| ' : ,---.               Running in stand alone mode, All function modules
| : : | ' ,'\ . --. . --.    Port: 8848
: : : ,,--. --.     ,---.  / / / / ' Pid: 10896
| : ' '; | / / \ / \.   ; ,. :| : /`. / Console: http://10.6.207.203:8848/nacos/index.html
' ' ;.    ;. --.  . --. | / / '' | |: :| : ;_
| | \ | \__\/: . ...    ' / ' | . ; : \ \ \ `.      https://nacos.io
' : | ; .' ," . --. ;' ; :__| : | `----.   \
| '`--' / / ,.  | '' | '.' | \ \ / / / `--' /
' : | ; : .'   \ : : `----' '--'.     /
| '.'     | , . -. /\ \ / `--'---'
'---' `--'---' `----'

2020-03-11 13:32:28.610 INFO 10896 --- [ main] o.s.cloud.context.scope.GenericScope : BeanFactory id=eda27c4d-5fc2-3c9d-8bf0-be5d7bdd58cd
2020-03-11 13:32:28.737 INFO 10896 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.security.config. annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration. ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$1c558beb] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-03-11 13:32:28.784 INFO 10896 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'objectPostProcessor' of type [org
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java: 515)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1105)
	at com.alibaba.nacos.config.server.service.DynamicDataSource.getDataSource(DynamicDataSource.java:54)
	at com.alibaba.nacos.config.server.service.PersistService.init(PersistService.java:91)
	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.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke( InitDestroyAnnotationBeanPostProcessor.java:363)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods( InitDestroyAnnotationBeanPostProcessor.java:307)
	at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization( InitDestroyAnnotationBeanPostProcessor.java:136)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization( AbstractAutowireCapableBeanFactory.java:414)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory. java:1770)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory. java:593)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java: 515)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1255)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1175)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject( AutowiredAnnotationBeanPostProcessor.java:595)
	at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
	at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties( AutowiredAnnotationBeanPostProcessor.java:376)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBe

上記は、すべてのコンソール出力は、私もインターネットを検索し、私は同じエラーを報告し、このほとんどは、com.mysql.jdbc.Driverを変更することはありません、あなたはに変更する必要があります:com.mysql.cj.jdbc.Driverを変更します。

神々に答えを求める