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

質問編集履歴

3

2021/08/07 07:31

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- wwwjava overridden method does not throw SQLExceptionが解決できません。
1
+ java overridden method does not throw SQLExceptionが解決できません。
body CHANGED
File without changes

2

www

2021/08/07 07:31

投稿

退会済みユーザー
title CHANGED
@@ -1,1 +1,1 @@
1
- java overridden method does not throw SQLExceptionが解決できません。
1
+ wwwjava overridden method does not throw SQLExceptionが解決できません。
body CHANGED
@@ -71,4 +71,30 @@
71
71
  エラーが発生したので、ググってみたら、 無効にされた方法は、SQLExceptionを投げないと出ました。
72
72
  try-catch追加や、exceptionの追加を試したのですが、エラーは消えませんでした。
73
73
  overridden method does not throw SQLException
74
- の解決法を教えて頂きたいです。
74
+ の解決法を教えて頂きたいです。
75
+
76
+
77
+ [修正後]
78
+ abstract class Operation throws SQLException, IOException {
79
+ protected ItemDAO model;
80
+ public Operation(ItemDAO model) {
81
+ this.model = model;
82
+ }
83
+
84
+ abstract public void execute() throws SQLException,IOException;
85
+ abstract public String getMenuNo();
86
+ abstract public String getMenuName();
87
+ }
88
+
89
+ ご回答いただき、ありがとうございます。
90
+ Operation クラスにthrows SQLException, IOExceptionを記載してませんでしたので、追加し、Operation クラスのexecute() と
91
+ 引数、型、メソッド名を同じか確認し、実行したのですが、
92
+ ./ShowItems.java:21: error: execute() in ShowItems cannot override execute() in Operation
93
+ public void execute()throws SQLException, IOException {
94
+ ^
95
+ overridden method does not throw SQLException
96
+ Note: Some input files use unchecked or unsafe operations.
97
+ Note: Recompile with -Xlint:unchecked for details.
98
+
99
+ 上記エラーが出て、エラー内容が変わりませんでした。execute()の下にエラーが出ているので、execute()に問題があると思うのですが、
100
+ わからず、すいませんが、アドバイス頂きたいです。

1

ええええええ

2021/08/07 07:17

投稿

退会済みユーザー
title CHANGED
File without changes
body CHANGED
@@ -48,7 +48,6 @@
48
48
 
49
49
  while( result.next() )
50
50
  {
51
- /*getString()メソッドは、引数に指定されたフィールド名(列)の値をStringとして取得する*/
52
51
  String str1 = result.getString( "itemCode" );
53
52
  String str2 = result.getString( "itemName" );
54
53
  int int3 = result.getInt( "price" );
@@ -70,5 +69,6 @@
70
69
  overridden method does not throw SQLException
71
70
 
72
71
  エラーが発生したので、ググってみたら、 無効にされた方法は、SQLExceptionを投げないと出ました。
72
+ try-catch追加や、exceptionの追加を試したのですが、エラーは消えませんでした。
73
73
  overridden method does not throw SQLException
74
74
  の解決法を教えて頂きたいです。