Error querying database cause



Error querying database cause

**Error exception: **org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory

Tools and environment

idea 2020.1, maven, spring-mvc, mybatis3.4.5, database mysql 8.0.18, mysql-connector-java 5.1.38

wrong description

In the past few days, I used spring-mvc to do a maven demo. When imitating the teacher to do the database connection part, there was an error like the title. After checking all afternoon, the problem could not be solved.
According to many statements on the Internet that the connector version of mysql does not correspond, etc., here is a summary of ideas.

1. Database version

If such errors occur, you must first determine your database version and targetVersion differences, Such as whether the mysql version matches the connector version, if you find that your version does not match, it is recommended to change to the adapted version, the mysql official website has a corresponding comparison of the connector and mysql version, if you feel troublesome, many blogs of great gods also get from the official website Version map.
Many students may install the compressed version of mysql server directly from the official website. Here I recommend using mysql installer. After using mysql installer, if you need to install another version of mysql server in the future , You can add the server directly from the top, and attach the software screenshot here:
Since this article mainly explains the author’s solution to the code error, the software installation and download process will not go into details, but only provide an idea.

2. Check the database configuration file

When I made a mistake, I checked the configuration file for an hour and found that there was indeed nothing wrong, but during the modification process, there was an error such as can’t load url. The reason is that there is a problem with your database connection url. When writing the database configuration file, the following errors are also likely to occur:
1. There is an end-of-line space or a space in a sentence in the datasource.properties file, (because I have not seen this error, I cannot explain it in detail, the author is still cute)
2. The key value in datasource.properties is wrong, it is recommended to write a more standard way of writing, such as: driverClassName => jdbc.driverClassName; other such as url, username, password is also recommended to add the same in front Prefix.
3. There is an error in the database mapper file of mybatis. If it is a SQL statement error, a prompt will be given in the error prompt.

Читайте также:  Ec file size input error

The author is also cute, and the mistakes will naturally be very stupid in the eyes of God. I solved this mistake today. I wrote this article on a whim and shared it with everyone. If there is a mistake, please correct me.

Источник

Error querying database cause

  • Mark as New
  • Bookmark
  • Subscribe
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Report Inappropriate Content

I’m using Activiti 5.22.0.0 on Oracle database and I’m getting the following error on execution of a process by Junit:

GRAVE: Error while closing command context
org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column ‘BYTES_’ from result set. Cause: java.sql.SQLRecoverableException: Error de E/S: Unexpected packet
### The error may exist in org/activiti/db/mapping/entity/Resource.xml
### The error may involve org.activiti.engine.impl.persistence.entity.ResourceEntity.selectResourcesByDeploymentId
### The error occurred while handling results
### SQL: select * from ACT_GE_BYTEARRAY where DEPLOYMENT_ID_ = ? order by NAME_ asc
### Cause: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column ‘BYTES_’ from result set. Cause: java.sql.SQLRecoverableException: Error de E/S: Unexpected packet
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:122)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:113)
at org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameter(DbSqlSession.java:440)
at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:431)
at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:426)
at org.activiti.engine.impl.db.DbSqlSession.selectList(DbSqlSession.java:403)
at org.activiti.engine.impl.persistence.entity.ResourceEntityManager.findResourcesByDeploymentId(ResourceEntityManager.java:45)
at org.activiti.engine.impl.persistence.entity.DeploymentEntity.getResources(DeploymentEntity.java:67)
at org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.deploy(BpmnDeployer.java:99)
at org.activiti.engine.impl.persistence.deploy.DeploymentManager.deploy(DeploymentManager.java:58)
at org.activiti.engine.impl.persistence.deploy.DeploymentManager.resolveProcessDefinition(DeploymentManager.java:185)
at org.activiti.engine.impl.persistence.deploy.DeploymentManager.findDeployedLatestProcessDefinitionByKey(DeploymentManager.java:147)
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:79)
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(StartProcessInstanceCmd.java:37)
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(CommandInvoker.java:24)
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(CommandContextInterceptor.java:57)
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(SpringTransactionInterceptor.java:47)
at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
at org.activiti.spring.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:45)
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(LogInterceptor.java:31)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:40)
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(CommandExecutorImpl.java:35)
at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(RuntimeServiceImpl.java:82)
at es.ocu.uxxi.ia.activiti.services.OCUProcessService.execProcessByKey(OCUProcessService.java:85)
at es.ocu.uxxi.ia.activiti.test.EjecutarCargaIACompletoTest.execCargaIATest(EjecutarCargaIACompletoTest.java:241)
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.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:73)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:82)
at org.activiti.engine.test.ActivitiRule$1.evaluate(ActivitiRule.java:126)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
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.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
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.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.apache.ibatis.executor.result.ResultMapException: Error attempting to get column ‘BYTES_’ from result set. Cause: java.sql.SQLRecoverableException: Error de E/S: Unexpected packet
at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:68)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getPropertyMappingValue(DefaultResultSetHandler.java:411)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(DefaultResultSetHandler.java:384)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(DefaultResultSetHandler.java:346)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(DefaultResultSetHandler.java:298)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(DefaultResultSetHandler.java:273)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(DefaultResultSetHandler.java:246)
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:160)
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:63)
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:78)
at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:62)
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:303)
at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:154)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:102)
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:82)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:120)
. 59 more
Caused by: java.sql.SQLRecoverableException: Error de E/S: Unexpected packet
at oracle.jdbc.driver.T4CConnection.getBytes(T4CConnection.java:2325)
at oracle.sql.BLOB.getBytes(BLOB.java:319)
at oracle.sql.BLOB.getBytes(BLOB.java:209)
at org.apache.ibatis.type.BlobTypeHandler.getNullableResult(BlobTypeHandler.java:43)
at org.apache.ibatis.type.BlobTypeHandler.getNullableResult(BlobTypeHandler.java:28)
at org.apache.ibatis.type.BaseTypeHandler.getResult(BaseTypeHandler.java:66)
. 74 more
Caused by: oracle.net.ns.NetException: Unexpected packet
at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:252)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:175)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:100)
at oracle.net.ns.NetInputStream.read(NetInputStream.java:85)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(T4CSocketInputStreamWrapper.java:122)
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.read(T4CSocketInputStreamWrapper.java:78)
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1179)
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1155)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:279)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:186)
at oracle.jdbc.driver.T4C8TTILob.read(T4C8TTILob.java:146)
at oracle.jdbc.driver.T4CConnection.getBytes(T4CConnection.java:2313)
. 79 more

Читайте также:  Open process failed error

I can’t see the cause of the problem. In some cases I’m getting the error, and in others cases (apparently wiht the same condiitions) it works fine.

Источник

Error querying database cause

This is due to the formatting exception of the mybatis parameter, such as the String type parameter and the number comparison in dynamic sql stitching.

Where xxx is a String type, and single quotes cannot be solved, such as: param.xxx != ‘Y’, at this time, mybatis thinks that comparing a string (String) with a character (char) will also give an error.
Therefore, there are several ways to solve this problem:
Solution

  1. Use toString() to convert to a string, ‘2’.toString()

2. Change to double quotes «2» and use single quotes on the outer layer.

3. Add escaped entity string quotes «

Intelligent Recommendation

Mybatis error querying database. Cause: java.lang.NullPointerException

Today, when I wrote a small demo about springboot, I always got an error querying database. Cause: java.lang.NullPointerException. Before and after carefully checking, I could n’t find where the.

【mybatis】Error querying database. Cause: java.lang.NullPointerException

When writing a statistics of Mapper today, I have already reported it when I test, the reason for the error is as follows: This is because of empty fingerError querying database. Cause: java.lang.Null.

Error querying database. Cause: java.lang.IllegalArgumentException: Mapped Statements collection XX

Original link: 1. Error code 2. Analyze the reason When configuring the mybatis-cofnig.xml file, the path to the mapper.xml configuration file was not added 3. Solution When configuring the mybatis-co.

mybatis error: java.lang.NumberFormatException: For input string: «A1»

MyBatis use, when used as the parameter map using map transmitted when transmission parameters and determining if test, an error may occur such as the title, specific information is given below: Analy.

Читайте также:  Error finding in english

Mybatis error: caused by: java.lang.numberformatexception: for input string: «xxxxxx»

Recently, I took over the project bug left on the previous colleague, and the error shown below appeared: From the above figure we can see that the numerical conversion exception, that is, the data of.

Источник

Оцените статью
toolgir.ru
Adblock
detector