日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

本文介紹了無法獲取Logback和MySQL連接的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我使用Logback和MySQL的方式如下:

<appender name="db" class="ch.qos.logback.classic.db.DBAppender">
    <connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
        <dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">
            <driverClass>com.mysql.jdbc.Driver</driverClass>
            <jdbcUrl>${jdbc.url}</jdbcUrl>
            <user>${jdbc.username}</user>
            <password>${jdbc.password}</password>
        </dataSource>

    </connectionSource>
</appender>

我得到的是:

    11:51:45,851 |-WARN in ch.qos.logback.core.db.DataSourceConnectionSource@4c1be833 - Could not get a connection to discover the dialect to use. java.sql.SQLException: Connections could not be acquired from the underlying database!
    at java.sql.SQLException: Connections could not be acquired from the underlying database!
    at  at com.mchange.v2.sql.SqlUtils.toSQLException(SqlUtils.java:106)
    at  at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:529)
    at  at com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource.getConnection(AbstractPoolBackedDataSource.java:128)
    at  at ch.qos.logback.core.db.DataSourceConnectionSource.getConnection(DataSourceConnectionSource.java:72)
    at  at ch.qos.logback.core.db.DataSourceConnectionSource.start(DataSourceConnectionSource.java:46)
    at  at ch.qos.logback.core.joran.action.NestedComplexPropertyIA.end(NestedComplexPropertyIA.java:167)
    at  at ch.qos.logback.core.joran.spi.Interpreter.callEndAction(Interpreter.java:318)
    at  at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:197)
    at  at ch.qos.logback.core.joran.spi.Interpreter.endElement(Interpreter.java:183)
    at  at ch.qos.logback.core.joran.spi.EventPlayer.play(EventPlayer.java:62)
    at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:147)
    at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:133)
    at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:96)
    at  at ch.qos.logback.core.joran.GenericConfigurator.doConfigure(GenericConfigurator.java:55)
    at  at ch.qos.logback.classic.util.ContextInitializer.configureByResource(ContextInitializer.java:75)
    at  at ch.qos.logback.classic.util.ContextInitializer.autoConfig(ContextInitializer.java:148)
    at  at org.slf4j.impl.StaticLoggerBinder.init(StaticLoggerBinder.java:84)
    at  at org.slf4j.impl.StaticLoggerBinder.<clinit>(StaticLoggerBinder.java:54)
    at  at org.slf4j.LoggerFactory.getSingleton(LoggerFactory.java:223)
    at  at org.slf4j.LoggerFactory.bind(LoggerFactory.java:120)
    at  at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:111)
    at  at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269)
    at  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)
    at  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)
    at  at com.grroo.manager.impl.AmazonEmailManagerImpl.<init>(AmazonEmailManagerImpl.java:42)
    at  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at  at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
    at  at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
    at  at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:74)
    at  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:958)
    at  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:911)
    at  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
    at  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
    at  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
    at  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
    at  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
    at  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
    at  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
    at  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
    at  at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
    at  at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
    at  at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
    at  at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4723)
    at  at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5226)
    at  at org.apache.catalina.core.StandardContext$1.call(StandardContext.java:5221)
    at  at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at  at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at  at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at  at java.lang.Thread.run(Thread.java:662)
Caused by: com.mchange.v2.resourcepool.CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.
    at  at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1319)
    at  at com.mchange.v2.resourcepool.BasicResourcePool.prelimCheckoutResource(BasicResourcePool.java:557)
    at  at com.mchange.v2.resourcepool.BasicResourcePool.checkoutResource(BasicResourcePool.java:477)
    at  at com.mchange.v2.c3p0.impl.C3P0PooledConnectionPool.checkoutPooledConnection(C3P0PooledConnectionPool.java:525)
    at  ... 51 common frames omitted
11:51:45,851 |-WARN in ch.qos.logback.core.db.DataSourceConnectionSource@4c1be833 - Connection does not support GetGeneratedKey method and could not discover the dialect.
11:51:45,854 |-ERROR in ch.qos.logback.core.joran.spi.Interpreter@14:13 - RuntimeException in Action for tag [appender] java.lang.IllegalStateException: DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect
    at java.lang.IllegalStateException: DBAppender cannot function if the JDBC driver does not support getGeneratedKeys method *and* without a specific SQL dialect
    at  at ch.qos.logback.core.db.DBAppenderBase.start(DBAppenderBase.java:62)
    at  at ch.qos.logback.classic.db.DBAppender.start(DBAppender.java:96)
    at  at ch.qos.logback.core.joran.action.AppenderAction.end(AppenderAction.java:96)

出了什么問題?
我使用的是MySQL-Connector-5.0.08,數據庫是MySQL 5.0.51

編輯:

我嘗試這樣添加<sqlDialect class="ch.qos.logback.core.db.dialect.MySQLDialect" />

<appender name="db" class="ch.qos.logback.classic.db.DBAppender">
        <connectionSource class="ch.qos.logback.core.db.DataSourceConnectionSource">
            <dataSource class="com.mchange.v2.c3p0.ComboPooledDataSource">
                <driverClass>com.mysql.jdbc.Driver</driverClass>
                <jdbcUrl>${jdbc.url}</jdbcUrl>
                <user>${jdbc.username}</user>
                <password>${jdbc.password}</password>
            </dataSource>

        </connectionSource>
                <sqlDialect class="ch.qos.logback.core.db.dialect.MySQLDialect" />`
    </appender>

但沒有成功!

推薦答案

問題是我錯過了logback-examples-1.0.0.jar

這篇關于無法獲取Logback和MySQL連接的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,

分享到:
標簽:Logback MySQL 獲取 連接
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定