Tag Archives: Exception

[exception] address already in use: bind

1. Problems:

Bind Exception:Address Already in use;
Failed to start connector;
Address Already in use:bind;
EmbeddedServletContainer Excepiton:Unable to start embedder Tomcat servlet container;
IllegalState Exception:Tomcat connector in failed state;

2. Source code:

None;

3. Screenshot:

4. Summary:

Here we put it java.exe Turn it all off;

[Java] Java program error: exception_ ACCESS_ VIOLATION (0xc0000005)

When running Java program, error: exception_ ACCESS_ VIOLATION (0xc0000005);

According to the description of the original webpage:

EXCEPTION_ACCESS_VIOLATION

In rare circumstances, a Java program could stop with a message similar to the following:
 An unexpected error has been detected by HotSpot Virtual Machine:
 EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c042340, pid=1743, tid=122
 Java VM: Java HotSpot(TM) Client VM (1.5.4_02)
Problematic frame:
C [ntdll.dll+0x2430]
Essentially, Java will stop with a message such as the above if a "serious" error occurs that means the JVM can't continue to function. Usually, the most discriminating line is the first mention of a DLL, such as the line in bold above. The source of the error could be any of the following:

 1. a bug in the JVM itself; search Google and/or the Java web site for
    a mention of ntdll.dll+0x2430;
 2. a bug in some non-Java code that was being run at the time: e.g.
    Java might have been calling into a printer driver, graphics driver
    etc.

If you're not sure what to do but are not using the latest version of the JVM for your system, then a good first course of action is usually to upgrade your JVM. If the bug is in some other DLL, e.g. a printer driver, database driver, graphics driver etc, then it is best to see if you can upgrade the component in question.

If the error is occurring in some native code that you have written, then you need to find out which line of code corresponds to the offset mentioned (in this case, 0x2430, although the DLL isn't one of ours in this example). Usually you can tell your compiler to generate a "map 

The possible reasons are as follows:
1. A bug in the JVM itself; search Google and/or the Java Web site for
a mention of ntdll.dll +0x2430;
For a bug in the JVM itself, visit Google or the Java website (according to ntdll.dll +A bug in some non java code that was being run at the time: e.g.
java might have been calling into a printer driver, Graphics driver
etc.
a bug in a running non java code may cause the print driver to be called, such as the graphics driver;

Here, my suggestions are:
1. The port number may conflict, so close other unnecessary Java programs;
2 2. For the same Java program, some function may be set to start automatically (which will crowd out the Java program you are using). If there is a pause button, pause the function in the same Java program first (without affecting it), run the part of your own function first, and then start other functions after running this part of your own function;

Welcome to my official account:
[screen bridge community]

org.springframework.dao.InvalidDataAccessApiUsageException: Bean object must not be null; nested exc

An error is reported when the project is started, and the entity class is null

org.springframework.dao.InvalidDataAccessApiUsageException: Bean object must not be null; nested exception is java.lang.IllegalArgumentException: Bean object must not be null
	at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:296)
	at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:108)
	at org.springframework.orm.jpa.AbstractEntityManagerFactoryBean.translateExceptionIfPossible(AbstractEntityManagerFactoryBean.java:403)
	at org.springframework.dao.support.ChainedPersistenceExceptionTranslator.translateExceptionIfPossible(ChainedPersistenceExceptionTranslator.java:58)
	at org.springframework.dao.support.DataAccessUtils.translateIfNecessary(DataAccessUtils.java:213)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:163)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.data.jpa.repository.support.LockModeRepositoryPostProcessor$LockModePopulatingMethodIntercceptor.invoke(LockModeRepositoryPostProcessor.java:92)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:91)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at com.sun.proxy.$Proxy22.save(Unknown Source)
	at cn.zx.ghjmaven.service.EmployeeServiceImpl.save(EmployeeServiceImpl.java:17)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
	at com.sun.proxy.$Proxy26.save(Unknown Source)
	at cn.zx.ghjmaven.action.bc.EmployeeAction.save(EmployeeAction.java:35)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:450)
	at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:289)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:252)
	at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:167)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265)
	at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:68)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:239)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:252)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
	at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:161)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
	at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
	at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
	at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:563)
	at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
	at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:501)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:170)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:950)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1040)
	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:607)
	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:313)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalArgumentException: Bean object must not be null
	at org.springframework.util.Assert.notNull(Assert.java:112)
	at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:213)
	at org.springframework.beans.BeanWrapperImpl.setWrappedInstance(BeanWrapperImpl.java:202)
	at org.springframework.beans.BeanWrapperImpl.<init>(BeanWrapperImpl.java:151)
	at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation$DirectFieldAccessFallbackBeanWrapper.<init>(JpaMetamodelEntityInformation.java:261)
	at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.getId(JpaMetamodelEntityInformation.java:107)
	at org.springframework.data.repository.core.support.AbstractEntityInformation.isNew(AbstractEntityInformation.java:51)
	at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.isNew(JpaMetamodelEntityInformation.java:190)
	at org.springframework.data.jpa.repository.support.SimpleJpaRepository.save(SimpleJpaRepository.java:357)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:344)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:329)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
	at org.springframework.dao.support.PersistenceExceptionTranslationInterceptor.invoke(PersistenceExceptionTranslationInterceptor.java:155)
	... 91 more

Solving failure executing javac, but could not parse the error

The following problems occurred during Maven install:

Failure executing javac, but could not parse the error: 

This kind of problem is generally caused by the configuration problem of JDK or JRE path. Check whether MyEclipse — & gt; preferences — & gt; Java — & gt; installed jres uses the path of self installed JRE.

Or check the configuration of environment variables, refer to http://jingyan.baidu.com/article/f96699bb8b38e0894e3c1bef.html  

After reconfiguring the environment variable path, it is solved because the JDK path is not configured properly.

“Failed to convert @ drawable / XX into a drawable exception details are logged in window”

Problem description

Image resource reference error, there are usually the following similar error logs:

java.lang.NumberFormatException: Color value 
'@drawable/xx' must start with #

reason

The most likely cause of this problem is that your image resource name is wrong, and it is likely to start with a number. In Android, if your image is named after a number, the system will treat it as a hexadecimal color value by default, and the definition of these color values often starts with “#”, so there is the following numberformatexception.

Solution

At this time, you need to check whether the name of the wrong resource starts with a number. If it starts with a number, rename it. If not, try to check whether the name of the resource starts with a space in eclipse (of course, the error at this time is that the drawable file cannot be found). If so, modify it. If not, delete the image and add it again.

After renaming, if the layout file cannot be displayed normally, refresh the preview of the layout view or restart the development tool.

Exception loading sessions from persistent storage

Tomcat error:
serious: IOException while loading persistent sessions: java.io.EOFException
Exception loading sessions from persistent storage

Error Description:
0 The session data stored in the hard disk failed to read. Eofexception indicates that the end of the file or the end of the file stream was unexpectedly reached during the input process, resulting in the failure of reading data from the session. This exception is a problem of Tomcat itself, generally because some active sessions were persisted when Tomcat was shut down abnormally last time. When Tomcat was restarted, Tomcat tried to recover these sessions N but failed to read

Solution:
find the corresponding project under Tomcat / work / Catalina / localhost session.ser File, and then delete it

The original text is reproduced from: http://blog.csdn.net/angeldhp/article/details/4742075

cvc-complex-type.2.3: Element ‘beans’ cannot have character [children]

When writing Spring’s ApplicationContext.xml file, out of nowhere:
CVC-Complex Type.2.3: Element ‘beans’ cannot have character [children], because the type’s content type is element-only. Error.

Error: Spring does not recognize the elements in ApplicationContext.xml when initialized.
Possible reasons for this error: The code copied online is pasted directly into an XML file, and the code on the Web may not conform to the XML specification

Remove the Chinese annotations from the XML file, because some of the annotations copied are not recognized by Spring.  
2. If there is still an error, try to modify the extra space, because Chinese space Spring may recognize the error.
3. Last resort: Copy the file again manually and save it.

Illegalargumentexception: control character in cookie value or attribute tomcat7

It is disgusting to encounter this exception. In Tomcat7 environment, this exception will be raised if the user’s name appears in Chinese when logging in. After the exception is caused, the user who cannot log in normally needs to delete the browser’s cookie information. Later, I checked the Internet and found out that the problem was Chinese transcoding. The abnormal information is as follows:

java.lang.IllegalArgumentException: Control character in cookie value or attribute.     
    at org.apache.tomcat.util.http.CookieSupport.isV0Separator(CookieSupport.java:155)     
    at org.apache.tomcat.util.http.Cookies.processCookieHeader(Cookies.java:323)     
    at org.apache.tomcat.util.http.Cookies.processCookies(Cookies.java:157)     
    at org.apache.tomcat.util.http.Cookies.getCookieCount(Cookies.java:98)     
    at org.apache.catalina.connector.CoyoteAdapter.parseSessionCookiesId(CoyoteAdapter.java:913)     
    at org.apache.catalina.connector.CoyoteAdapter.postParseRequest(CoyoteAdapter.java:683)     
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:400)     
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:964)     
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:515)     
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:304)     
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)     
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)     
    at java.lang.Thread.run(Thread.java:662)   

Cookie is encoded by Unicode in Chinese and ASCII in English when storing the value, so the data needs to be transcoded when storing the Chinese value, and the data also needs to be transcoded when storing the value.
There are two solutions, one is a Cookie written in Java, and the other is a Cookie written in JavaScript.
The solution is as follows:
Java:

Encode: URLEncoder. Encode (name, “UTF-8”);
Decode.decode (name, “UTF-8”);
Decode.decode (name, “UTF-8”);

JavaScript:

Code: the escape (name);/encodeURI(name);
decode: unescape(name);/decodeURI(name);

The Servlet setting cookies to view the article: http://blog.csdn.net/twilight041132/article/details/46482983

Wrong installation of registry to registry

Today, when I was installing Git’s latest version, which is currently 2.5.0, the last step of the installation produced an error as shown in the figure below:


interface on the error message when you can easily see that is written to the registry has been refused to visit, I was thinking whether the registry permissions is not enough, with the right to administrator rights to install again, installed in the end, and the error, and the Internet, may be the version is too new, and not a lot of online solutions, find the solution with administrator rights to install, can I have confirmed that this is not enough. It also says that ignoring the error can be used, but since it is an error, it must be fixed.
After consideration, since you do not have the right to write to the registry, simply enter the corresponding registry, change the registry permissions, the location of the registry is the registry location in the error message above, enter, right click and select modify permissions:


Then, reinstall, and the error is perfectly resolved.

python: HTTP Error 505: HTTP Version Not Supported

The urlliB2 module of Python is used to obtain the data code as follows:

Try:
    data = urllib2.urlopen(url).read()
except Exception,e:
    print e
return data

Url parameter is:

http://sms.gildata.com:8080/sms/sendSms.do?content=Hello world&msisdns=18373239087&user=gildata2&key=804

The following problems occurred while executing the code:
HTTP Error 505: the HTTP Version Not Supported
online are urllib2 module does Not support http1.1 agreement, must carry on the processing of one sort or another, but I later found out that seems to be the url does Not support Spaces, I will Hello world this parameter Spaces take out, can successfully send text messages to come out, if it is in space can be used to add escape character % 20 instead of Spaces, you can also use % 0 a instead of a newline.

Error 1045 (28000): solution to access denied for user ‘root’ @’localhost ‘(using password: no)


This problem was encountered when installing MySQL service under Windows, which was installed with MySQL green version. After installation, when connecting to MySQL service, enter the command “mysql-uroot-p”. Because the password was not set for the first login, the error message was as follows:
“ERROR 1045 (28000): Access Denied for user ‘root’@’localhost’ (using password: NO)”

The diagram below:

Solutions:
First you need to turn off the MySQL service and enter the command:
mysql> net stop MySQL
To start the local MySQL service in safe mode (note: launch the CMD window as an administrator), enter the command “MySQld — Defaults file=”G:\Install_Applications\ mysql.8.0.11 \ My.ini” –console –skip-grant — tables “to start the MySQL service, the cursor will stop without any output, which indicates that the MySQL service has been started.

Start the CMD window, and enter the command “mysql-uroot-p” to directly enter and log in to the mysql server, and then modify, you can enter the command:
(before 5.7.11) & GT; update user set password=password(“123456″) where user=”root”;

(5.7.11 or later) & GT; update user set authentication_string=password(“123456″) where user=”root”;
Here I’m using:
mysql> ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘HuaZai12345! ‘;
The diagram below:

Now exit, enter the command “mysql-uroot-p” and enter the password just set, and you can log in to the mysql server normally, as shown in the figure below:

Ok, this is the solution for ERROR 1045 (28000): Access Denied for user ‘root’@’localhost’ (using password: NO). If you have any questions, please feel free to leave me a message.

: “learn together, make progress together”, I also hope that we will pay more attention to the IT community of CSND.

Error: current transaction is aborted, commands ignored until end of transaction blockp

In normal database programming, we encountered errors from time to time: Current Transaction is aborted, commands ignored until the end of transaction BlockP. How to solve it?We usually look it up on the Internet. If you’re a little bit better at English you can tell from the error message that there’s probably something wrong there. But if the experience is not very rich, or the Internet to find more convenient. The most basic error message can see from the official documentation (http://www.postgresql.org/docs/8.4/interactive/errcodes-appendix.html).
The error above is the cause of improper transaction control, which can be written as follows.
Improper writing 1:
Connection OPEN.
Try {
Try {
Database operation A.
} Catch (Exception e) {
The log. The error (” do something “);
}
 
Database operation B. // The above error may occur during this data operation.
The transaction commits commit.
} Catch (Exception ex) {
Transaction rollback rollback.
} the finally {
Close the connection.
}
 
Improper writing method 2:
Connection OPEN.
Try {
Database operation A.
Database operation B.
The transaction commits commit.
} Catch (Exception ex) {
Database operation C. // The above error may occur during this data operation.
The transaction commits commit.
} the finally {
Close the connection.
}
 
In a Postgres database, if there is an error in a database operation in the same transaction, all subsequent databases in that transaction will fail.
If there is an error in database operation A, the same database operation B will report an error when it is executed. If there is an error in database operation A or database operation B, the same database operation C will report an error.
To avoid errors, someone is using the re-open method, which in effect throws away all previous operations (not in the case of auto-commit) and adds overhead by re-opening, which is not recommended.
Depending on the cause of the error, we can treat the processing before the possible error as a transaction. The processing after the error is then treated as a transaction, depending on the specific logic. That way you can avoid making mistakes.
In this way, we can change the improper 1 to
Try {
Database operation A.
} Catch (Exception e) {
Transaction rollback or commit;
The log. The error (” do something “);
}
Database operation B.  
 
In this way we can change the improper notation 2 to
} Catch (Exception ex) {
Transaction rollback or commit;
Database operation C.   
The transaction commits commit.
} the finally {
Close the connection.
}