Category Archives: How to Fix

Group by query only_ FULL_ GROUP_ By error

The ONLY_FULL_GROUP_BY error in the Group by query

The initial version of mysql for Windows (5.7.28) was used in the project, but later when migrating to Linux, some SQL queries experienced the error ONLY_FULL_GROUP_BY, because MySQL5.7 default set mysql SQL_mode = ONLY_FULL_GROUP_BY attribute, which caused an error (Windows version has no default).
MySQL also provides an any_value() function to suppress ONLY_FULL_GROUP_BY if the business must use a non-grouped field

Vscode configuration connection server docker write code

The configuration steps
2. Local Docker service 3. Vscode configuration 4. use

1. Generate SSH key pairs
Ssh-keygen
all the way enter, default sound generated two files:
id_rsa
id_rsa.pub
transfer to the server, copy into a file: ~/.ssh/authorized_keys
if there is, add to the following
cat id_rsa.pud > > ~/.ssh/authorized_keys
2. Local Docker service
Docker “host= SSH ://@”
docker context create –docker “host= SSH :// @”
switch to this context:
docker context use
test :
docker info
3. Vscode configuration
Install plug-in
remote developement
docker
Use 4.
Attach Remote Host Container
server run docker
open vscode, hold shift+ CTRL +p, run docker contexts use
press shift+ CTRL +p, run remot-containers :Attach to Running Containers… , select the docker container running
and successfully press shift+k to open the docker container directory

Error creating project by Vue yorkie: command failed

After long unused VUE, I needed to create a VUE project: VUE Create MyAPP, then prompted whether to change the image to taobao image, and finally reported yorkie: Command failed.
After many attempts, it failed, and finally
cancel taobao mirror
NPM config delete registry
Vue Create + MyProject succeeded!
There are so many mistakes, different reasons, different solutions.

Wireshark filtering HTTP packets

Wireshark Filter: Protocol = “HTTP” displays filtered HTTP packets

    List item

Using the filter
built into the wireshark tool, directly click “filter “, open the “display filter” dialog box, select “HTTP”, and then click “Expression” to use the filter condition expressions identified by the tool.

Exception: jupyter command Jupiter notebook not found

Open jupyter notebook times error Exception: jupyter command jupyter-noteboook not found.


at this time you can choose to enter pip3 install jupyter notebook to reinstall the notebook, it appears as follows:

namely the notebook has been installed, the current available version version 20.3.1, and we are using version 20.3
The solution
WARNING: enter the command line as c:\python38\ python.exe-m PIP install –upgrade PIP

version after the update can reopen jupyter notebook

Webpack encountered a variety of problems to solve

The overview of WebPack is not much longer.
Let me go straight to some of the problems I encountered in learning WebPack.
Problem 1: An error has been reported during the installation of the partial WebPack and the installation failed.
The common reason for this is that when you execute NPM init-y, the “name” attribute in the package.json file is called “Webpack” by default, which will result in repeated name errors.


Question 2: When you install WebPack Webpack-CLI (I think it was in 4. After a few versions you must install webpack-cli) webpack-dev-server, execute
NPM run dev. Report an error finding that a file in the webpack directory cannot be found. This is usually due to version incompatibility.
I recommend you check out an answer from the nuggets, linked below
About the version of the three plug-ins
These are the problems that newcomers generally encounter. In fact, when they encounter these problems, there are no more than the following situations:

    version is not compatible without permissions local and global problems network speed has a problem, the package did not download good

So you find the error message first, and then you get a sense of what it means. If you still can’t figure it out, ask the search engines. Slowly narrow down the bug, and that’s it

Encapsulation of adding, deleting and modifying database by JDBC

private static final String CLASS_FORNAME = "com.mysql.jdbc.Driver";
private static final String URL = "jdbc:mysql://127.0.0.1:3306/test";
private static final String USER = "ROOT";
private static final String PASSWORD = "123456";

static{
    try {
        Class.forName(CLASS_FORNAME);
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
}

public static Connection getConn(){
    try {
        return DriverManager.getConnection(URL,USER,PASSWORD);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return null;
}

public static void close(Connection conn, Statement ps, ResultSet rs){
    try {
        conn.close();
        ps.close();
        rs.close();
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
public static boolean update(String sql,Object...obj){
    Connection conn = getConn();
    PreparedStatement ps = null;
    try{
        ps =conn.prepareStatement(sql);
        if (Objects.nonNull(obj)) {
            for (int i = 0; i < obj.length; i++) {
                ps.setObject(i+1,obj[i]);
            }
        }
        int b = ps.executeUpdate();
        return b >0;
    } catch (SQLException e) {
        e.printStackTrace();
    }finally {
        close(conn,ps,null);
    }
    return false;
}

Thinking: the JDBC database operation step cannot modify data set as a constant, then the access to database objects and close the resources as method, will be updated as method, namely the deletion operation, the operation of SQL to update for us, then the array as the incoming conditions, first of all determine whether array is empty, if the data is not empty

File under WGet download directory

Wget downloads all the contents under a certain folder in Tsinghua Source
Website: https://mirrors.tuna.tsinghua.edu.cn/hugging-face-models/hfl/chinese-roberta-wwm-ext/

wget -r -np -nH -R index.html --limit-rate=2M https://mirrors.tuna.tsinghua.edu.cn/hugging-face-models/hfl/chinese-roberta-wwm-ext/

-r: Traverse all subdirectories -NP: less than the previous level of subdirectories to -nh: Do not save files to the hostname folder -r index.html: do not download index.html files –limit-rate: is the speed limit
Results:

Click the button to use in the react project window.open Methods open a new page and click the data again

Problem description
When use the react to do background management program, there is a demand, a list can be according to the conditions of the query, there is a printing function, print is the data of the current query conditions, click on the print button, use the window. The open () method to open the new page, and set the position of open the window, to print the data in a new window display, the real printing function is realized in a new window.

at this time there is a problem, to print the data I am existing in localstorage, when the first open new window, click on the print button to print the data is correct, but if I open the window, not closing new from the previous page to change the terms of the query, click print again, open the last failed to shut down the page, the page does not automatically refresh, also won’t get the latest localstorage inside the value of the printed data is not new.

When I wrote window.location.href directly in componentDidMount, since componentDidMount is the life cycle that executes after the page has been loaded, and the page refresh cycle will be infinite, so this method does not work. I want to try to add a judgment condition, such as whether a value exists in localStorage is equal, but after the value in localStorage changes, both pages will change, so it will always be equal.
Finally, I changed an idea and found a way to listen for changes in the value of localStorage. In a new window, I can listen for changes in the value of localStorage stored in the previous page. If there is any change, I will perform the operation of refreshing the page.

window.addEventListener("storage", function(e) {
    console.log(e)
    window.location.reload()
});

Different files in the same domain will detect changes in stored values. Same file, store value changes, cannot be monitored.
the operation to store the data can be placed at the click of the print button to open the new page, so that the data in the new window does not change until after the click
For this problem, there should be other solutions, thank you added.

In J2EE Tomcat webapps, there are only folder directories and no files

Problem description:
j2ee web debugging process I found that no matter how I modified it did not change, and then I clean it, but after this program can not run, 404 can not find resources.


Reason analysis:
checked the path of the release project
controller in classes these folders are all directories, no files, after searching baidu, it should be a reference project lack of jar package, leading to the project build failure, but the empty directory was built, leading to this problem.


Solutions:
once I know what the problem is, I remove the jar from the path and add it again, and the project runs.

Django. Using f () to solve the competition problem

What are the competition issues:
When multiple users operate on a field at the same time, there is no expected return.
F () function:

from django.db.models import F

def vote(request, choice_id):
    selected_choice = question.choice_set.get(pk=request.POST['choice'])
    selected_choice.votes = F('votes') + 1
    selected_choice.save()