亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Spring?myBatis數(shù)據(jù)庫(kù)連接異常問(wèn)題及解決

 更新時(shí)間:2022年06月06日 09:39:08   作者:vera_vera_vera  
這篇文章主要介紹了Spring?myBatis數(shù)據(jù)庫(kù)連接異常問(wèn)題及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

spring myBatis數(shù)據(jù)庫(kù)連接異常

報(bào)錯(cuò)如下

org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.
### The error may exist in file [E:\Code_zxt\MVNWebDemo\target\classes\mapper\SeckillDao.xml]
### The error may involve org.seckill.dao.SeckillDao.queryById
### The error occurred while executing a query
### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.


at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:76)
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:399)
at com.sun.proxy.$Proxy13.selectOne(Unknown Source)
at org.mybatis.spring.SqlSessionTemplate.selectOne(SqlSessionTemplate.java:165)
at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:69)
at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:53)
at com.sun.proxy.$Proxy14.queryById(Unknown Source)
at org.seckill.dao.SeckillDaoTest.TestQueryById(SeckillDaoTest.java:38)
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.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:73)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:224)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:83)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:68)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:163)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: org.apache.ibatis.exceptions.PersistenceException: 

首先去看mysql服務(wù)是否啟動(dòng),發(fā)現(xiàn)啟動(dòng)正常。

再去看jdbc.properties文件里面url username等寫(xiě)對(duì)沒(méi)有,寫(xiě)的是正確的,但是發(fā)現(xiàn)password是unused。去看spring-dao.xml(spring和mybatis相關(guān)的配置文件),發(fā)現(xiàn)漏寫(xiě)了password的“}”

如下:

myBatis連接數(shù)據(jù)庫(kù)時(shí)報(bào)錯(cuò)原因歸納

報(bào)錯(cuò)信息

org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:oracl


### The error may exist in sqlMapper/UsersMapper.xml
### The error may involve test.findUserById
### The error occurred while executing a query
### Cause: java.sql.SQLException: Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
The Connection descriptor used by the client was:
localhost:1521:oracl

這里報(bào)錯(cuò)的可能性在于配置文件中的jdbc.url=jdbc:oracle:thin:@localhost:1521:oracl的oracl不是Oracle數(shù)據(jù)庫(kù)的SID,數(shù)據(jù)庫(kù)的SID是orcl,所以會(huì)報(bào)這個(gè)錯(cuò),可以通過(guò)服務(wù)查看Oracle的SID進(jìn)行核對(duì) 

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • 深入理解Java中HashCode方法

    深入理解Java中HashCode方法

    這篇文章主要介紹了深入理解Java中HashCode方法,具有一定借鑒價(jià)值,需要的朋友可以參考下
    2018-01-01
  • Java FastJson使用教程

    Java FastJson使用教程

    這篇文章主要介紹了如何使用FastJson,幫助大家將 Java 對(duì)象轉(zhuǎn)換為 JSON 格式,感興趣的朋友可以了解下
    2020-10-10
  • Java實(shí)現(xiàn)BASE64編碼和解碼的方法

    Java實(shí)現(xiàn)BASE64編碼和解碼的方法

    本篇文章主要介紹了Java實(shí)現(xiàn)BASE64編碼和解碼的方法,BASE64編碼通常用于轉(zhuǎn)換二進(jìn)制數(shù)據(jù)為文本數(shù)據(jù),有需要的可以了解一下。
    2016-11-11
  • Mybatis中 XML配置詳解

    Mybatis中 XML配置詳解

    這篇文章主要介紹了Mybatis中 XML配置詳解的相關(guān)資料,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下
    2017-01-01
  • Java transient關(guān)鍵字原理解析

    Java transient關(guān)鍵字原理解析

    這篇文章主要介紹了Java transient關(guān)鍵字原理解析,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-01-01
  • spring中的注解@@Transactional失效的場(chǎng)景代碼演示

    spring中的注解@@Transactional失效的場(chǎng)景代碼演示

    這篇文章主要介紹了spring中的注解@@Transactional失效的場(chǎng)景代碼演示,@Transactional注解是Spring框架提供的用于聲明事務(wù)的注解,作用于類(lèi)和方法上,需要的朋友可以參考下
    2024-01-01
  • 用Java實(shí)現(xiàn)希爾排序的示例

    用Java實(shí)現(xiàn)希爾排序的示例

    問(wèn)題:現(xiàn)有一段程序S,可以對(duì)任意n個(gè)數(shù)進(jìn)行排序。如果現(xiàn)在需要對(duì)n^2個(gè)數(shù)進(jìn)行排序,最少需要調(diào)用S多少次?只允許調(diào)用S,不可以做別的操作。我們用希爾排序來(lái)做解決這個(gè)
    2013-11-11
  • springboot 增加過(guò)濾器方法操作示例

    springboot 增加過(guò)濾器方法操作示例

    這篇文章主要介紹了springboot 增加過(guò)濾器方法操作,結(jié)合實(shí)例形式分析了springboot過(guò)濾器配置、加載等相關(guān)操作技巧,需要的朋友可以參考下
    2019-12-12
  • SpringBoot集成WebSocket長(zhǎng)連接實(shí)際應(yīng)用詳解

    SpringBoot集成WebSocket長(zhǎng)連接實(shí)際應(yīng)用詳解

    這篇文章主要介紹了SpringBoot集成WebSocket長(zhǎng)連接實(shí)際應(yīng)用詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-06-06
  • Spring boot監(jiān)控Actuator-Admin實(shí)現(xiàn)過(guò)程詳解

    Spring boot監(jiān)控Actuator-Admin實(shí)現(xiàn)過(guò)程詳解

    這篇文章主要介紹了Spring boot監(jiān)控Actuator-Admin實(shí)現(xiàn)過(guò)程詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-09-09

最新評(píng)論