Tag Archives: database

[Solved] com.alibaba.druid.pool.DruidDataSource – create connecti

A service deployed in the server docker reported the following error when connecting to the database:

I have searched a lot of information on the Internet, but I can’t solve it by trying various ways,
ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url: jdbc:mysql://10.10.20.16:3306/acs?&useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Kolkata, errorCode 0, state 08S01
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

The specific error information is as follows:

ERROR com.alibaba.druid.pool.DruidDataSource – create connection SQLException, url: jdbc:mysql ://10.10.20.16:3306/acs?& amp; useUnicode=true& characterEncoding=UTF-8& zeroDateTimeBehavior=convertToNull& allowMultiQueries=true& serverTimezone=Asia/Kolkata, errorCode 0, state 08S01
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure

The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.

Cause of error:

It may be due to the different versions of JDK. This error message is probably caused by the SSL protocol of MySQL

solution: I tried to remove SSLv3 from java.security in jdk-8 on my local machine and restart the service, but I still couldn’t solve it
finally, add this to the MySQL connection string in the service configuration; Usessl = false, that is, disable SSL, problem solved

The COMMIT TRANSACTION request has no corresponding BEGIN

Background

Error thrown when inserting data into SQL Server database using Python:

Cannot commit transaction: (3902,b'The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
DB-Lib error message 20018, severity 16:\nGeneral SQL Server error:Check messages from the SQL Server\n')

analysis

Well, there’s no reason. But a solution was found by accident.

solve

The error caused by the field type in sqlserver. The error I encountered is: one of the fields is set to date type. When inserting data, I report an error. Change the date type to varchar type, the problem is solved, and the data is inserted normally.

Summary

The varchar type may affect the data usage. Solve the problem first, and then solve the problem later. I think that inserting varchar data into the database is the most stable (personal experience).


Personal ability is limited, if there is a mistake welcome to correct!

PLSQL environment variable configuration tnsnames.ora file path

1、 Directory structure

D:\install\PLSQL
    |-- instantclient_11_2
        |-- tnsnames.ora
    |-- PLSQL Developer
    |-- readme.txt

2、 Environment variables
you must configure environment variables, otherwise the database fields will be added with random comments

NLS_LANG = SIMPLIFIED CHINESE_CHINA.ZHS16GBK

TNS_ADMIN = D:\install\PLSQL\instantclient_11_2

3、 PL/SQL developer environment settings

1. Location

    Tools -> Preferences -> Connections

2. Settings

    Oracle home directory name = D:\install\PLSQL\instantclient_11_2

    OCI library = D:\install\PLSQL\instantclient_11_2\oci.dll 

4. Supplement

The tnsnames.ora file needs to be created manually and set up accordingly, refer to the online tutorial.

Problem: you need to modify the tnsnames.ora file to configure the database connection, but you can’t find the path of the file. Many online searches say that it’s in the app directory of disk D, but you still can’t find it.

Solution: open PL/SQL and find help – & gt; Support information
after opening, you will see the PL/SQL version information and other configuration information. If you pull down, there will be a “TNS file”, which is the tnsnames.ora file path of the PL/SQL you installed. After modification, you need to restart PL/SQL

How to release Oracle PLSQL data lock table

(1)See which table is locked
select b.owner,b.object_name,a.session_id,a.locked_mode from vKaTeX parse error: Expected ‘EOF’, got ‘#’ at position 115: …,b.sid,b.serial#̲,logon_time fro…locked_object a,v$session b where a.session_id = b.sid order by b.logon_time;
(3)Kill the corresponding process
Execute the command: alter system kill session ‘1025,41’; (pay attention to the problem of spaces in the middle)
Here is the main point

---Lock table query SQL

SELECT object_name, machine, s.sid, s.serial# ,o.owner

FROM gv$locked_object l, dba_objects o, gv$session s 

WHERE l.object_id = o.object_id 

AND l.session_id = s.sid; 

Use this query to look up the locked object, the locking table device, and the sid and serial

2
--Force process shutdown

alter system kill session '1434, 2425';

Here 1434 and 2425 are the sid and serial of the previous query, respectively

3
--When 'ORA-00030: User session ID does not exist' appears

--query process number

select distinct s.sid,s.serial#,p.spid as system process number

from v$locked_object l , dba_objects o , v$session s , v$process p

where l.object_id=o.object_id and l.session_id=s.sid and s.paddr=p.addr;

4
Log in to the database server using the Xshell tool and execute the following command.

kill -9 system process number

The system process number is the spid queried in the previous step

 

At this point, the table locking problem can be solved perfectly!

ERROR 2000 (HY000): Unknown MySQL error

After the installation of mysql5.7 physical machine, modify the binlog log in my.cnf, restart mysql, log in and connect to MySQL with the client of the machine, and report error 2000 (HY000): unknown MySQL error. This error will also be reported when mysqldump exports data of all tables,

solve:

1. When using systemctl restart mysqld, you can’t connect by using Navicat, but after using systemctl stop mysqld, you can connect by using systemctl start mysqld, but you still can’t export data by using mysqldump connection.

2. Directly back up the data file on MySQL, and then use docker to install mysql5.7, copy the data file to/var/lib/MySQL, a permission error will be reported, and then change the permission to chown mysql:mysql datadir Can be used normally, user name root password root

reference resources: https://dba.stackexchange.com/questions/91712/whats-causing-this-error-2000-hy000-unknown-mysql-error

Solution to “[dbnetlib] [connectionwrite (send()).] general network error”

Recently, I need to use Excel to generate a series of charts, the data is naturally obtained through sql server. The problem is that this excel has nearly 50 charts, and each chart has to be connected to DB to get the data. The problem comes, when refreshing all the time often encountered
“[DBNETLIB] [ConnectionWrite (send()). General network error. Check your network documentation” error. The initial judgment is definitely too much data connection caused by (for Excel rookies do not have the ability to solve from the Excel side). After a while Google, finally found a solution, maybe not the best, right as a record.

Possible causes.
This problem occurs because Windows Server 2003 and higher implements a security feature that reduces the size of the queue of concurrent TCP/IP connections to the server. This feature helps prevent denial-of-service attacks. Under high load conditions, the TCP/IP protocol may incorrectly recognize a valid TCP/IP connection as a denial-of-service attack. This behavior can lead to the problems described in the Symptoms section.

Solution.
This section, method, or task contains steps that tell you how to modify the registry. However, serious problems can occur if the registry is not modified correctly. Therefore, make sure you follow these steps carefully. For extra protection, back up the registry before modifying it. Then, if a problem occurs, you can restore the registry.
To resolve this issue, turn off this new feature by adding SynAttackProtect entry to the following registry entry for the computer that is running Microsoft SQL Server, which houses your BizTalk server database.

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Tcpip \ \ Service Parameters

Settings

SynAttackProtect

Enter a DWORD value of 00000000. to do this, follow these steps:
Click Start, click Run, type regedit, and then click OK. Find and click on the following registry entry:

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Tcpip \ \ Service Parameters

On the Edit menu, point to New, then click on the DWORD value. Type SynAttackProtect, and then press ENTER. Click Modify on the Edit menu. In the Value Data box, type 00000000. click OK. exit the Registry Editor.
Note To complete this registry change, you must restart the computer running SQL Server.

 

MYSQL 5.7 Error Code: 1290. The MySQL server is running with the –secure-file-priv option so it..

When exporting data with MySQL 5.7, an error was reported. The error was reported as follows:

Error Code: 1290. The MySQL server is running with the --secure-file-priv option so it cannot execute this statement

According to the wrong information, we found that secure-file-priv will specify the folder as the place where the exported files are stored, so we can find this folder first.

Solution 1:

enter the following command in the MySQL command line interface:

show variables like '%secure%';


Annotated is the correct file path, we will export files in this directory.
For SQL instructions, modify as follows:

SELECT * FROM User details WHERE gender='male'
INTO OUTFILE 'C:\\ProgramData\\MySQL\\MySQL Server 5.7\\Uploads\\man.txt'

The file can be successfully exported to this directory.
Solution 2:
Go to the installation path C:\ProgramData\MySQL\MySQL Server 5.7, find my. Ini file and modify the default save path of Secure-file-priv.
Secure_file_prive =null — mysqld does not allow import and export
secure_file_priv=/ TMP/– limits the import and export of mysqld to only occur in the/TMP/directory
secure_file_priv= “” — does not restrict the import and export of mysqld

When the database table field is set to self incrementing, use the entity class to insert or update the data to solve the error (Hibernate Framework)

Problem: there are self increasing columns in database table fields. When you add or update data using entity classes, you will report an error (Hibernate Framework)

[2021-05-06 15:12:04] [WARN] [org.hibernate.engine.jdbc.spi.SqlExceptionHelper:143] SQL Error: -2664, SQLState: 22000
[2021-05-06 15:12:04] [ERROR] [org.hibernate.engine.jdbc.spi.SqlExceptionHelper:144] Fehler bei Zeile 1:
Versuch, die selbstinkrementierende Spalte [NUM] zu ändern
org.hibernate.exception.DataException: Fehler bei Zeile 1:
Versuch, die selbstinkrementierende Spalte [NUM] zu ändern
	at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:134)
	at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:49)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125)
	at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110)
	at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:146)
	at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
	at com.sun.proxy.$Proxy502.prepareStatement(Unknown Source)
	at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.buildBatchStatement(AbstractBatchImpl.java:144)
	at org.hibernate.engine.jdbc.batch.internal.AbstractBatchImpl.getBatchStatement(AbstractBatchImpl.java:127)
	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2964)
	at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2915)
	at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:3244)
	at org.hibernate.action.internal.EntityUpdateAction.execute(EntityUpdateAction.java:113)
	at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:362)
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:354)
	at org.hibernate.engine.spi.ActionQueue.executeActions(ActionQueue.java:276)
	at org.hibernate.event.internal.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:326)
	at org.hibernate.event.internal.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:59)
	at org.hibernate.internal.SessionImpl.autoFlushIfRequired(SessionImpl.java:1099)
	at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1528)
	at org.hibernate.internal.CriteriaImpl.list(CriteriaImpl.java:374)
	at org.jeecgframework.core.common.dao.impl.GenericBaseCommonDao.findByPropertys(GenericBaseCommonDao.java:184)
	at org.jeecgframework.core.common.service.impl.CommonServiceImpl.findByPropertys(CommonServiceImpl.java:145)
	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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
	at com.sun.proxy.$Proxy80.findByPropertys(Unknown Source)
	at com.aisino.platform.lhjh.service.impl.FgwLhjhZbServiceImpl.doTzAudit(FgwLhjhZbServiceImpl.java:538)
	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.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
	at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:98)
	at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:262)
	at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:95)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207)
	at com.sun.proxy.$Proxy208.doTzAudit(Unknown Source)
	at com.aisino.platform.lhjh.controller.FgwLhjhZbController.doAudit(FgwLhjhZbController.java:524)
	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.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
	at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137)
	at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:747)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:676)
	at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:938)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:870)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:961)
	at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
	at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:837)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at filter.FrameTao.doFilter(FrameTao.java:22)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.jeecgframework.core.aop.GZipFilter.doFilter(GZipFilter.java:114)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.springframework.orm.hibernate4.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:150)
	at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:543)
	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
	at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:690)
	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:615)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:818)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1626)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)
Caused by: dm.jdbc.driver.DMException: Fehler bei Zeile 1:
Versuch, die selbstinkrementierende Spalte [NUM] zu ändern
	at dm.jdbc.driver.DBError.throwException(DBError.java:636)
	at dm.jdbc.c.b.p.S(MSG.java:225)
	at dm.jdbc.c.b.p.P(MSG.java:185)
	at dm.jdbc.c.b.p.O(MSG.java:166)
	at dm.jdbc.c.a.a(DBAccess.java:786)
	at dm.jdbc.c.a.a(DBAccess.java:206)
	at dm.jdbc.driver.DmdbPreparedStatement.prepareSql(DmdbPreparedStatement.java:198)
	at dm.jdbc.driver.DmdbPreparedStatement.allocateHandle(DmdbPreparedStatement.java:167)
	at dm.jdbc.driver.DmdbPreparedStatement.<init>(DmdbPreparedStatement.java:120)
	at dm.jdbc.driver.DmdbPreparedStatement.<init>(DmdbPreparedStatement.java:134)
	at dm.jdbc.driver.DmdbConnection.do_prepareStatement(DmdbConnection.java:791)
	at dm.jdbc.driver.DmdbConnection.do_prepareStatement(DmdbConnection.java:777)
	at dm.jdbc.driver.DmdbConnection.prepareStatement(DmdbConnection.java:1395)
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:476)
	at com.alibaba.druid.filter.FilterAdapter.connection_prepareStatement(FilterAdapter.java:929)
	at com.alibaba.druid.filter.FilterEventAdapter.connection_prepareStatement(FilterEventAdapter.java:122)
	at com.alibaba.druid.filter.FilterChainImpl.connection_prepareStatement(FilterChainImpl.java:473)
	at com.alibaba.druid.proxy.jdbc.ConnectionProxyImpl.prepareStatement(ConnectionProxyImpl.java:342)
	at com.alibaba.druid.pool.DruidPooledConnection.prepareStatement(DruidPooledConnection.java:349)
	at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138)
	... 102 more

Solution: add the properties insertable = false and updatable = false to the @ column annotation with self increasing attribute fields.

@Column(name = "num", insertable = false, updatable = false)
    private Integer num;

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your

Error: ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘‘stock’(
‘id’ int unsigned auto_increment,
‘number’ int (10) not null,
‘name’ va’ at line 1

The reason for this is that the quotation marks should be used for the reason that the English quotation marks, i.e., the – symbol in the key below the esc key on the keyboard has a ~ and – key, are used as quotation marks.