Only the first part of the error message is posted here

java.sql.SQLException: Can not issue data manipulation statements with executeQuery().
    at com.mysql.jdbc.Statement.checkForDml(Statement.java:302)
    at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1148)
    at com.lmm.loginDao.UserDao.addUser(UserDao.java:54)
    at com.lmm.test.UserDaoTest.testAddUser(UserDaoTest.java:22)
    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)
Copy the code

This error was encountered while unit testing with JUnit5 to add users, and when resolved, record the resolution

ExcecuteQuery () is used instead of excecuteUpdate() for insert,delete, or update operations. ExecuteQuery () statements are statements that are used to produce a single result set, such as a SELECT statement. When you use executeQuery(), after your database has stored the data, you need to query. ExecuteUpdate () : Used to execute insert, update, or DELETE statements. The return value is the number of rows affected. Execute () runs the statement and returns whether there is a result set.