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 file, (because I have not seen this error, I cannot explain it in detail, the author is still cute)
2. The key value in 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 on Oracle database and I’m getting the following error on execution of a process by Junit:

GRAVE: Error while closing command context
### 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(
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(
at org.activiti.engine.impl.db.DbSqlSession.selectListWithRawParameter(
at org.activiti.engine.impl.db.DbSqlSession.selectList(
at org.activiti.engine.impl.db.DbSqlSession.selectList(
at org.activiti.engine.impl.db.DbSqlSession.selectList(
at org.activiti.engine.impl.persistence.entity.ResourceEntityManager.findResourcesByDeploymentId(
at org.activiti.engine.impl.persistence.entity.DeploymentEntity.getResources(
at org.activiti.engine.impl.bpmn.deployer.BpmnDeployer.deploy(
at org.activiti.engine.impl.persistence.deploy.DeploymentManager.deploy(
at org.activiti.engine.impl.persistence.deploy.DeploymentManager.resolveProcessDefinition(
at org.activiti.engine.impl.persistence.deploy.DeploymentManager.findDeployedLatestProcessDefinitionByKey(
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(
at org.activiti.engine.impl.cmd.StartProcessInstanceCmd.execute(
at org.activiti.engine.impl.interceptor.CommandInvoker.execute(
at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(
at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(
at org.activiti.spring.SpringTransactionInterceptor.execute(
at org.activiti.engine.impl.interceptor.LogInterceptor.execute(
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(
at org.activiti.engine.impl.cfg.CommandExecutorImpl.execute(
at org.activiti.engine.impl.RuntimeServiceImpl.startProcessInstanceByKey(
at es.ocu.uxxi.ia.activiti.test.EjecutarCargaIACompletoTest.execCargaIATest(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
at org.junit.runners.model.FrameworkMethod.invokeExplosively(
at org.junit.internal.runners.statements.InvokeMethod.evaluate(
at org.junit.internal.runners.statements.RunBefores.evaluate(
at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(
at org.junit.internal.runners.statements.RunAfters.evaluate(
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(
at org.activiti.engine.test.ActivitiRule$1.evaluate(
at org.junit.rules.RunRules.evaluate(
at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(
at org.junit.runners.ParentRunner.runLeaf(
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(
at org.junit.runners.ParentRunner$
at org.junit.runners.ParentRunner$1.schedule(
at org.junit.runners.ParentRunner.runChildren(
at org.junit.runners.ParentRunner.access$000(
at org.junit.runners.ParentRunner$2.evaluate(
at org.junit.internal.runners.statements.RunBefores.evaluate(
at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(
at org.junit.internal.runners.statements.RunAfters.evaluate(
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(
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(
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getPropertyMappingValue(
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.applyPropertyMappings(
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getRowValue(
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValuesForSimpleResultMap(
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleRowValues(
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSet(
at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(
at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(
at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(
at org.apache.ibatis.executor.SimpleExecutor.doQuery(
at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(
at org.apache.ibatis.executor.BaseExecutor.query(
at org.apache.ibatis.executor.CachingExecutor.query(
at org.apache.ibatis.executor.CachingExecutor.query(
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(
. 59 more
Caused by: java.sql.SQLRecoverableException: Error de E/S: Unexpected packet
at oracle.jdbc.driver.T4CConnection.getBytes(
at oracle.sql.BLOB.getBytes(
at oracle.sql.BLOB.getBytes(
at org.apache.ibatis.type.BlobTypeHandler.getNullableResult(
at org.apache.ibatis.type.BlobTypeHandler.getNullableResult(
at org.apache.ibatis.type.BaseTypeHandler.getResult(
. 74 more
Caused by: Unexpected packet
at oracle.jdbc.driver.T4CSocketInputStreamWrapper.readNextPacket(
at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(
at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(
at oracle.jdbc.driver.T4CTTIfun.receive(
at oracle.jdbc.driver.T4CTTIfun.doRPC(
at oracle.jdbc.driver.T4CConnection.getBytes(
. 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: != ‘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:

  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.


Оцените статью