Author Archives: Robins

[Solved] Spring Error: java.sql.SQLException: Access denied for user ‘${user}’@’localhost’ (using password: YES)

Spring properties configuration file problem

error message

Spring loads JDBC Error in properties content, original configuration file:

Error message:

Solution:

When connecting to the database, the role name of root should be root@localhost. The role name of root reporting error here is Sang@localhost , sang here is the user name of idea. When idea loads root, it automatically replaces root with sang, so use Sang@localhost An error will be reported when connecting to the database.

Solution 1: modify the configuration file to

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/hellospring?serverTimezone=UTC
user=root
password=123456

Modification method 2: modify the configuration file to

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/hellospring?serverTimezone=UTC
jdbc.username=root
jdbc.password=123456

Importerror: no module named * [How to Solve]

1. Question

After switching the project from pycharm to sublime text, it is found that a * Py file, the module cannot be found.

2. Cause

When you start the interpreter in the IDE, the current working directory is the project directory, which can successfully call the modules in the same project; However, when you start from the command line, the current working directory is the directory where you started the interpreter. If the current location is not the project directory, the modules in the project directory will not be found. Therefore, an error is reported when running: modulenotfounderror: no module named

3.Solution

Method 1: put the module path into the environment variable as a global variable

Method 2: Add sys.path.append (project directory) at the beginning of the running file

[Solved] Spring MVC cross server upload error: returned a response status of 405 method not allowed

The error of uploading picture newspaper 405 across servers is because Tomcat is read-only by default. We turn off read-only and allow adding files instead.

Solution: Find the web.xml file in the tomcat installation directory, open it and add the following code in the servlet:

<!– Allow Tomcat server to add files — >

< init-param>
< param-name> readonly
< param-value> false

[Solved] 64-bit Python calls 32-bit Oracle client error: Cx_Oracle.DatabaseError: DPI-1047

problem

The operating system is 64 bit Python and 32 bit Oracle client. For other reasons, the Oracle client cannot be changed to 64 bit, resulting in Cx_Oracle64 bit cannot be used, CX_Oracle32 bit cannot be installed.

reason

Under Windows environment, if 64 bit Python is installed, CX_Oracle is used, the 64 bit Oracle client is called by default. In this case, we can only install Cx_Oracle win_Amd 64-bit version.

Solution:

1. First install CX_Oracle matching the current Python version, my is Python 3.8. The installed version is: Cx_Oracle-8.3.0-cp38-cp38-win_amd64.whl

2. Download the relevant Oracle instantclient (instant client) and unzip it to a folder convenient for calling

Download address: https://www.oracle.com/database/technologies/instant-client/winx64-64-downloads.html

The version I downloaded is: instantclient-basiclite-windows-x64-19.13.0.0.0dbru.Zip, you can try several times, there is always one for you

3. Unzip the instantclient and change the environment variable in the Python code to adjust the Oracle driver location.

My unzipped address is:

E:\software\Python\instantclient-basiclite-windows.x64-19.13.0.0.0dbru

The code adjustment method is

import os

os.environ[‘path’] =  r’E:\software\Python\instantclient-basiclite-windows.x64-19.13.0.0.0dbru\instantclient_19_13′

import cx_Oracle

Now CX_Oracle can call normally

How to Solve Error in redis insertion list

When the position of the class changes or other effects change the serialization ID, the previously serialized list cannot be deserialized. Instead of resetting the list, setlist adds the list later.

When the following code cannot be serialized, it will always set the list, which will cause the list to be too large. When you request the list again, it will report that redis cannot be connected

report errors

Solution:

Replace with string, and check whether there is the use of redis’s setlist when changing the location of the class

[Solved] Chrome Browser uploads files for a long time interrupts and reports an error: net :: ERR_NETWORK_IO_SUSPENDED

Upload large files, obtain the upload progress through the interface, and constantly update the progress. If the browser is not operated for about 20 minutes, the upload will be interrupted and an error net:: err will be reported_ NETWORK_ IO_ SUSPENDED

reason:

It is a protection mechanism of Google browser. If the web page is not operated for 15 minutes, the network request will be interrupted.

Solution:

Create a div with an interval of time to simulate the mouse click event and automatically trigger the click.

let  timeDiv = document.createElement('div');
document.body.appendChild(timeDiv);

interval = setInterval(()=>{
      timeDiv && timeDiv.click();
},1000*10);

[Solved] python Connect Oracle Error: DPI-1047

Prompt when Python connects to Oracle:: databaseerror: dpi-1047: cannot locate a 64 bit Oracle Client Library: “the specified module could not be found” See https://oracle.github.io/odpi/doc/installation.html#windows for help

Enter according to the error prompt https://oracle.github.io/odpi/doc/installation.html#windows, download the corresponding instant client package, then unzip the configuration environment variables and run it again. Generally, it can run successfully to solve the problem.

If dpi-104 error is still prompted, you need to check whether VC + + is installed. The check method is to run genezi.com under the downloaded instant client directory Exe program. For example: C:\Oracle\instantclient_21_3\genezi.exe. If there is an error during execution, it means VC_redist is not installed correctly. reenter https://oracle.github.io/odpi/doc/installation.html#windows Page, download the corresponding VC according to the corresponding Oracle version_redist.exe version.

Download and install to solve the problem.

[Solved] Mybatis error: attempted to return null from a method with a primitive return type (int)

1. Origin of the problem

When viewing the log, I found that a line of error message was printed in the log:

The data of assembled pets that have been released is abnormal — & gt; Mapper method ‘applets. user. mapper. xxxMapper. xxxmyRank attempted to return null from a method with a primitive return type (int).

The meaning is well understood. The query method of xxxmyrank in a mapper file returns null, but it needs to return an int type number, so an error is reported.

2. Problem analysis

Fdafdsaf query is a simple query used to query a ranking. If you query the ranking yourself, you can use int type to receive it. At the beginning of the test, there was no problem, but after the project was really launched

Report this problem before you know that this problem exists in the previously written code. The reason for this problem is that the database does not query the corresponding data, so it returns a null value. When you write your own code, you use the int type receive. As shown in the figure below:

3. Solution

After finding the cause of the problem, it is easy to solve it. Change the received int type to the wrapper type integer type class for reception, so as to solve this problem. Because the integer type can be null, regardless of the specific value returned

Or a null value, can receive. Then, you can process the null value in the code, and the problem is solved.

Expansion: this method is mainly used in query. When writing custom numeric fields in Java code, it is best to use the wrapper type to receive them,

Byte,Boolean,Short ,Character,Integer,Long,Float,Double.

The principle is the same. If you query the entity class or use the entity class to accept the value passed by the front end, there may be no value null. At this time, using the wrapper type can solve this problem.