Tag Archives: database

[BUG-mybatis-plus] org.postgresql.util.PSQLException: ERROR: syntax error at or near “current_date“

Environmental Science:

         spring cloud   + Mybatis-plus + postgresql

Scenario:

  Prompt during table insertion

         org.postgresql.util.PSQLException: ERROR: syntax error at or near “current_date”

  Causes:

         current_ Date() is the method of SQL, current_ Date is the method name

resolvent:

         current_ Change date to create_ Date (optional here, not the method name)

Analysis process:

         The Error statement in XML file and navigator displays current_ Date is green (keyword color)

 

 

Error running ‘Application‘: Command line is too long [How to Solve]

2021.11.18

When idea starts a new project, a pop-up prompt error is encountered

Error running ‘xxx Application’:Command line is too lang. Shorten command line for Application or aalso for Spring Boot default configuration

Error reason: the springboot project startup command is too long

Solution:

The first method (protest is effective)

Step 1: find the idea/workspace.xml file in the project, and then find <component name="PropertiesComponent"> </component > tag, as shown below

step2:Add a line to the component tag < property name="dynamic.classpath" value="true"/>, as shown below

Restart the project.

[Solved] ERROR com.alibaba.druid.pool.DruidDataSource – init datasource error, url jdbcmysql

Error reporting when deploying an open source project

ERROR com.alibaba.druid.pool.DruidDataSource - init datasource error, url jdbcmysql://

Obviously, there is a database connection error

But after eliminating the error, I can find the real cause of the error

Database connection address error

Network problems

Wrong user name and password

Finally, it was found that there was a problem with the MySQL driver version of the open source project, which was inconsistent with the MySQL I installed

Solution:

Go to POM.XML and delete the version information of MySQL, which can be used by default, as shown below

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

[Solved] Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.Mon Nov 15 20:44:52 CST 2021
There was an unexpected error (type=lnternal Server Error, status=500).
Could not open JPA Entity/Manager for transacton, nested exception is org.hibernate.exceptionGenericDBCException:
Unable to acquireJDBCConnection

During the debugging of idea, I encountered a problem on the browser side. I found it for many days and finally solved it. That is, the JDBC version of the connection between idea and MySQL does not match. Let’s share the method below
if you see an error, it is probably a JDBC connection problem. First, check the configured MySQL user name, password and URL

After making sure that everything is correct, check whether my MySQL version corresponds to the idea version. Before I made an error, the MySQL jar package in the idea is 5.0, but my idea version is higher than mysql, so I can’t connect. Then I go to the MySQL 8.0 jar package under the official website, import it into the idea, and then change the JDBC version in pom.xml


  • In the higher version of JDBC, spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver is generally added with a cj.

This is the previous
this is the current

later, there will be no JDBC connection problem when running on the server side! This is my problem solved, others may have more situations. Here only represents my own solution!

java.sql.SQLRecoverableException: IO Error: Connection reset

I wrote an executable jar package to execute on Linux, connected to Oracle 11g database and obtained database data. It was always the card owner. When it timed out, it ran out with an error message. The server could be restarted several times, and it was stuck later.

Execute jar package statement

/root/jdk1.8.0_ 181/bin/java -jar GetJdbc-1.0-SNAPSHOT.jar

java.sql.SQLRecoverableException: IO Error: Connection reset
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:421)
        at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:531)
        at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:221)
        at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
        at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:503)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:247)
        at com.iwhalecloud.jdbc.utils.GetDataSource.getConnection(GetDataSource.java:27)
        at com.iwhalecloud.jdbc.execute.DistinguishDataSource.oracleQuery(DistinguishDataSource.java:78)
        at com.iwhalecloud.jdbc.execute.DistinguishDataSource.dataHandle(DistinguishDataSource.java:34)
        at com.iwhalecloud.jdbc.main.MainProgram.main(MainProgram.java:26)
Caused by: java.net.SocketException: Connection reset
        at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:115)
        at java.net.SocketOutputStream.write(SocketOutputStream.java:155)
        at oracle.net.ns.DataPacket.send(DataPacket.java:199)
        at oracle.net.ns.NetOutputStream.flush(NetOutputStream.java:211)
        at oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:227)
        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.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:366)
        at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:752)
        at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:359)
        ... 10 more
close
Exception in thread "main" java.lang.NullPointerException
        at com.iwhalecloud.jdbc.execute.DistinguishDataSource.oracleQuery(DistinguishDataSource.java:80)
        at com.iwhalecloud.jdbc.execute.DistinguishDataSource.dataHandle(DistinguishDataSource.java:34)
        at com.iwhalecloud.jdbc.main.MainProgram.main(MainProgram.java:26)

Find an effective solution on the Internet and add a parameter – DJava. Security. EGD = file:/dev /../dev/urandom

The execution statement is as follows

/root/jdk1.8.0_ 181/bin/java -jar -Djava.security.egd=file:/dev/../dev/urandom GetJdbc-1.0-SNAPSHOT.jar

Error: Java: error: release version 5 not supported solution to run error

Error reporting reason

Java compiler setting error in project structure or setting

resolvent

1. Project structure
Click f I l e → P R O j e c t s t r u c t u r e file \ rightarrow project structurefile → projectstructure

Ensure that the SDK versions under project are the same

2、Preferences

    Click setting in preferences (or win version) to search java compiler and ensure that the target byte code
    version is the same as the selected version

[Solved] Linux Mongodb Error: # Error: coul-bash: connecting: command not found

1. MongoDB error content and solution
This is an error when entering mongo startup

[root@g3dhkzznakmqafv5-1029528 mongodb]# Error: coul-bash: connecting: command not found
.1:27017 :: caused by :: Connection refused :ction attempt failed: SocketException: Error connecting to 127.0.0
[1]+ Exit 127 connecting to: mongodb://127.0.0.1:27017/?compressors=disabled
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
Change the permission of .sock file.

Next, we check the error report of the MongoDB log

"ctx":"SignalHandler","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2021-11-14T21:50:59.901+08:00"},"s":"I",  "c":"NETWORK",  "id":23017,   "ctx":"listener","msg":"removing socket file","attr":{"path":"/tmp/mongodb-27017.sock"}}
{"t":{"$date":"2021-11-14T21:50:59.901+08:00"},"s":"I",  "c":"NETWORK",  "id":4784905, "ctx":"SignalHandler","msg":"Shutting down the global connection pool"}

Solution:

The above log has said to remove mongodb-27017.sock in the/tmp directory
here, you can switch to the TMP directory to view the mongodb-xxx.sock file
remove the mongodb-27017.sock file, and then restart OK successfully
if you have tried to switch ports, remove all mongodb-xxx.sock files

[Solved] Mybatis integrates PageHelper and uses sqlserver paging error

The environment uses mybatis plus, the paging plug-in: PageHelper 5.2.0, and the database uses sqlserver2012 or above

In fact, the paging plug-in is ultimately handled by the mybatis interceptor, so it is equivalent to the mybatis environment.

Using paging

 PageHelper.startPage(1,10); // Pagination
  orderMapper.list(); // Follow the execution

Then an error will be reported

SQL: SELECT  id,product_name,xxxx,xxxxx  FROM product_xxxx  OFFSET ?ROWS FETCH NEXT ?ROWS ONLY
### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: “@P0”There is a grammatical error nearby.
; uncategorized SQLException; SQL state [S0001]; error code [102]; There is a syntax error near "@P0". ; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: There is a syntax error near "@P0".

Finally, after checking, it is found that the paging syntax offset and fetch used by PageHelper are sqlserver’s support for sorting.

Therefore, if you want to use this plug-in to page, you need to add sorting.

PageHelper.startPage(1,10,"xxxx sorted table field name, not attribute name");
orderMapper.list(); // Follow the execution

Or use the default sort field

PageHelper.startPage(1,10,"CURRENT_TIMESTAMP");
orderMapper.list(); //Follow up

[Solved] XML file configuration database connection information logical symbol error

Reason: illegal escape characters. XML characters must be replaced with corresponding entities.

- &lt;    <(Less than)
-&gt; > (greater than)
-&amp; & (and)
-&apos; '(single quote)
-&quot; "(double quotation mark)

Solution:

Follow the shortcut keys prompted by idea to replace

        <property name="DriverClass">com.mysql.cj.jdbc.Driver</property>
        <property name="JdbcUrl">jdbc:mysql://localhost:3306/test?characterEncoding=utf8&amp;ampuseSSL=false&amp;serverTimezone=UTC&amp;rewriteBatchedStatements=true</property>
        <property name="User">root</property>
        <property name="Password">789756long</property>

[Solved] mysqldump Command Error: Got error: 2002: “Can‘t connect to server on ‘127.0.0.1‘ (36)“ when trying to connect

1. When executing mysqldump command for data backup, the error information is as follows:

~ % mysqldump -udbuser -p123456 -h127.0.0.1 school student  > school_student.sql 
mysqldump: Got error: 2002: "Can't connect to server on '127.0.0.1' (36)" when trying to connect

2. Then try the command line to connect to the database, which is also an error

~ % mysql -udbuser -p123456 -h127.0.0.1
ERROR 2002 (HY000): Can't connect to server on '127.0.0.1' (36)

3. After checking the MySQL service result, I remembered that I used ‘mysql. Server start’ to start the database. This cannot follow the system startup. Each time I restart the Mac, I need to run it manually. You can use brew services to start MariaDB   Start the service with the system.

~ % mysql.server start
Starting MariaDB
.211111 16:04:44 mysqld_safe Logging to '/usr/local/var/mysql/xiaokang.err'.
211111 16:04:44 mysqld_safe Starting mariadbd daemon with databases from /usr/local/var/mysql
 SUCCESS! 

4. After successful restart, execute mysqldump again for backup