The main solution is as follows:
1. mysql's authorized user permissions must be % instead of @ localhost
2. The connection characters used by jsp to connect to the database using the jdbc driver should be considered as remote access.
3. Remember: @ % indicates the remote permission. @ localhost actually only has the local permission.
Maybe I am too stupid to torture me for more than a month. This problem has been unable to connect to the database, the header is too big because I am used to deleting three redundant accounts in the user table after installing mysql to enhance security, so this problem has never been solved (but it seems that there is a problem if I don't delete it? After all, these accounts are not @ %), and the cause is always not found. At the prompt of CU, I still want to thank them (although I didn't give me the actual solution ), later, I checked the overseas BBS based on the error information and found a similar answer to the same error, however, a foreigner asked me to change the localhost in the connection string to the actual domain name or IP address. I tried it, but it didn't work, but I suddenly thought about it, an account @ % was added to the test! I'm in a good mood and don't get depressed any more. Also, let's say that the mysql database only has the privilege of managing the root account, and other accounts have no right to limit it.
I hope my experiences can help others!
The following is the jsp script used for testing. Make sure that you have a test table in the test database before testing.
Two fields and several rows of input data.
<% @ Page contentType = "text/html; charset = gb2312" %>
<% @ Page import = "java. SQL. *" %>
<Html>
<Body>
<% Class. forName ("com. mysql. jdbc. Driver"). newInstance ();
String url = "jdbc: mysql: // localhost/test? User = test & password = test & useUnicode = true & characterEncoding = 8859_1 ";
// Assume that test is your database.
Connection conn = DriverManager. getConnection (url );
Statement stmt = conn. createStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet. CONCUR_UPDATABLE );
String SQL = "select * from test ";
// Read data from the test table
ResultSet rs1_stmt.exe cuteQuery (SQL );
While (rs. next () {%>
The content of your first field is: <% = rs. getString (1) %>
Your second field content is: <% = rs. getString (2) %>
<% }%>
<% Out. print ("database operation successful, congratulations"); %>
<% Rs. close ();
Stmt. close ();
Conn. close ();
%>
</Body>
</Html>