質問編集履歴
1
コードとエラー内容の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,3 +27,167 @@
|
|
27
27
|
Eclipse Photon 4.8.0
|
28
28
|
|
29
29
|
MySQL 8.0.11
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
以下、該当コードとエラー内容です。
|
36
|
+
|
37
|
+
**DbUtility.java**
|
38
|
+
|
39
|
+
```Java
|
40
|
+
|
41
|
+
package jp.co.db;
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
import java.sql.Connection;
|
46
|
+
|
47
|
+
import java.sql.DriverManager;
|
48
|
+
|
49
|
+
import java.sql.SQLException;
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
public class DbUtil {
|
54
|
+
|
55
|
+
public static Connection dbConnect() throws SQLException, ClassNotFoundException {
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
Class.forName("com.mysql.jdbc.Driver");
|
60
|
+
|
61
|
+
// Connectionの生成
|
62
|
+
|
63
|
+
Connection con = DriverManager.getConnection(
|
64
|
+
|
65
|
+
"jdbc:mysql://localhost:3306/mysql?serverTimezone=UTC" // データベース
|
66
|
+
|
67
|
+
, "achm" // ユーザ
|
68
|
+
|
69
|
+
, "nia" // パスワード
|
70
|
+
|
71
|
+
);
|
72
|
+
|
73
|
+
System.out.println(con);
|
74
|
+
|
75
|
+
return con;
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
public static void dbClose(Connection con) throws SQLException{
|
84
|
+
|
85
|
+
con.close();
|
86
|
+
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
```Error
|
100
|
+
|
101
|
+
java.sql.SQLException: null, message from server: "Host 'localhost' is not allowed to connect to this MySQL server"
|
102
|
+
|
103
|
+
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965)
|
104
|
+
|
105
|
+
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:898)
|
106
|
+
|
107
|
+
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:887)
|
108
|
+
|
109
|
+
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1038)
|
110
|
+
|
111
|
+
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2190)
|
112
|
+
|
113
|
+
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2221)
|
114
|
+
|
115
|
+
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2016)
|
116
|
+
|
117
|
+
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:776)
|
118
|
+
|
119
|
+
at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
|
120
|
+
|
121
|
+
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
|
122
|
+
|
123
|
+
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
|
124
|
+
|
125
|
+
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
|
126
|
+
|
127
|
+
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)
|
128
|
+
|
129
|
+
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
|
130
|
+
|
131
|
+
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:386)
|
132
|
+
|
133
|
+
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:330)
|
134
|
+
|
135
|
+
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:678)
|
136
|
+
|
137
|
+
at java.sql/java.sql.DriverManager.getConnection(DriverManager.java:229)
|
138
|
+
|
139
|
+
at jp.co.db.DbUtil.dbConnect(DbUtil.java:12)
|
140
|
+
|
141
|
+
at jp.co.ClientLogin.clientLogin(ClientLogin.java:18)
|
142
|
+
|
143
|
+
at jp.co.ClientLoginServlet.doPost(ClientLoginServlet.java:32)
|
144
|
+
|
145
|
+
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
|
146
|
+
|
147
|
+
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
|
148
|
+
|
149
|
+
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
|
150
|
+
|
151
|
+
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
|
152
|
+
|
153
|
+
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
|
154
|
+
|
155
|
+
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
|
156
|
+
|
157
|
+
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
|
158
|
+
|
159
|
+
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
|
160
|
+
|
161
|
+
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
|
162
|
+
|
163
|
+
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
|
164
|
+
|
165
|
+
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
|
166
|
+
|
167
|
+
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
|
168
|
+
|
169
|
+
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
|
170
|
+
|
171
|
+
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
|
172
|
+
|
173
|
+
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
|
174
|
+
|
175
|
+
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
|
176
|
+
|
177
|
+
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
|
178
|
+
|
179
|
+
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
|
180
|
+
|
181
|
+
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
|
182
|
+
|
183
|
+
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
|
184
|
+
|
185
|
+
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
|
186
|
+
|
187
|
+
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
|
188
|
+
|
189
|
+
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
|
190
|
+
|
191
|
+
at java.base/java.lang.Thread.run(Thread.java:844)
|
192
|
+
|
193
|
+
```
|