teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

ご指摘いただいた通り、マークダウンを使い、ファイルごとに細分化し、エラーログも記載しました。よろしくお願い致します。(文字制限に引っかかったため、いらない部分は一部省略しています)

2021/09/29 13:15

投稿

mario11222
mario11222

スコア4

title CHANGED
File without changes
body CHANGED
@@ -11,12 +11,8 @@
11
11
  https://teratail.com/questions/230629
12
12
  https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q12217713427
13
13
 
14
- ### 発生している問題・エラーメッセージ
15
- デバックでDAOの「pStmt1.setString(3,encryption.seacret(ab.getPass()));」
16
- にカーソルを合わせた際にでたメッセージがcom.mysql.cj.jdbc.ClientPreparedStatement: INSERT INTO ACCOUNT(NAME,MAIL,PASS) VALUES('湊 一郎','ichirou@gmail.com',** NOT SPECIFIED **)→NOT SPECIFIEDが問題だと思ってます。
17
-
18
14
  ### 該当のソースコード
19
- JavaBeans
15
+ ```JavaBeans
20
16
  package model;
21
17
 
22
18
  import java.io.Serializable;
@@ -59,17 +55,11 @@
59
55
  this.pass = pass;
60
56
  }
61
57
  }
62
-
58
+ ```
59
+ ```Java
63
60
  暗号化のメソッド
64
61
  package model;
65
62
 
66
- import java.nio.charset.Charset;
67
- import java.nio.charset.StandardCharsets;
68
- import java.security.MessageDigest;
69
- import java.security.NoSuchAlgorithmException;
70
-
71
- import javax.xml.bind.DatatypeConverter;
72
-
73
63
  public class Encryption {
74
64
 
75
65
  public String seacret(String password) {
@@ -93,19 +83,10 @@
93
83
 
94
84
  }
95
85
 
96
-
86
+ ```
97
- DAO
87
+ ```DAO
98
88
  package dao;
99
89
 
100
- import java.sql.Connection;
101
- import java.sql.DriverManager;
102
- import java.sql.PreparedStatement;
103
- import java.sql.ResultSet;
104
- import java.sql.SQLException;
105
-
106
- import model.Encryption;
107
- import model.User;
108
-
109
90
  public class RegisterDAO {
110
91
 
111
92
  // データベース接続に使用する情報
@@ -181,24 +162,10 @@
181
162
 
182
163
  }
183
164
  }
184
-
165
+ ```
185
- サーブレット
166
+ ```サーブレット
186
167
  package servlet;
187
168
 
188
- import java.io.IOException;
189
-
190
- import javax.servlet.RequestDispatcher;
191
- import javax.servlet.ServletException;
192
- import javax.servlet.annotation.WebServlet;
193
- import javax.servlet.http.HttpServlet;
194
- import javax.servlet.http.HttpServletRequest;
195
- import javax.servlet.http.HttpServletResponse;
196
- import javax.servlet.http.HttpSession;
197
-
198
- import dao.RegisterDAO;
199
- import model.Encryption;
200
- import model.User;
201
-
202
169
  /**
203
170
  * Servlet implementation class Register
204
171
  */
@@ -256,8 +223,8 @@
256
223
  }
257
224
 
258
225
  }
259
-
226
+ ```
260
- jsp
227
+ ```jsp
261
228
  <%@ page language="java" contentType="text/html; charset=UTF-8"
262
229
  pageEncoding="UTF-8"%>
263
230
  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
@@ -268,38 +235,6 @@
268
235
  <title>登録</title>
269
236
  </head>
270
237
  <body>
271
- <script type="text/javascript">
272
- window.onload = function(){
273
- const btnSubmit = document.getElementById("btnSubmit");
274
- const inputName = document.getElementById("inputName");
275
- const inputMail = document.getElementById("inputMail");
276
- const reg = /^[A-Za-z0-9]{1}[A-Za-z0-9_.-]*@{1}[A-Za-z0-9_.-]{1,}.[A-Za-z0-9]{1,}$/;
277
-
278
- btnSubmit.addEventListener("click",function(event){
279
- let message = [];
280
- /*入力値チェック*/
281
- if(inputName.value == ""){
282
- message.push("氏名が未入力です。");
283
-
284
- }
285
- if(inputMail.value == ""){
286
- message.push("メールアドレスが未入力です。")
287
-
288
- }else if(!reg.test(inputMail.value)){
289
- message.push("メールアドレスの形式が不正です");
290
-
291
- }
292
- if(message.length > 0){
293
- alert(message);
294
- event.preventDefault();
295
- return;
296
- }
297
- alert("入力チェックOK");
298
- });
299
-
300
- };
301
-
302
- </script>
303
238
  <h1>ユーザー登録画面</h1>
304
239
  <div id = "message">
305
240
  </div>
@@ -311,6 +246,39 @@
311
246
  </form>
312
247
  </body>
313
248
  </html>
314
-
249
+ ```
250
+ ```log
251
+ com.mysql.cj.jdbc.exceptions.MysqlDataTruncation: Data truncation: Data too long for column 'pass' at row 1
252
+ at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:104)
253
+ at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:953)
254
+ at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1092)
255
+ at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1040)
256
+ at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1347)
257
+ at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1025)
258
+ at dao.RegisterDAO.AccountRegister(RegisterDAO.java:50)
259
+ at servlet.Register.doPost(Register.java:56)
260
+ at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)
261
+ at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
262
+ at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:292)
263
+ at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
264
+ at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
265
+ at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:240)
266
+ at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:207)
267
+ at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:212)
268
+ at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:94)
269
+ at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:141)
270
+ at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
271
+ at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:620)
272
+ at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88)
273
+ at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:502)
274
+ at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1132)
275
+ at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:684)
276
+ at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1539)
277
+ at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1495)
278
+ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
279
+ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
280
+ at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
281
+ at java.lang.Thread.run(Thread.java:748)
282
+ ```
315
283
  ### 試したこと
316
284
  DAOに暗号化の処理を入れてダメだったのでサーブレットのuser.setPass(pass);に暗号化の処理を施したが、うまくいきませんでした。