質問編集履歴

1

javaコード追記 修正

2016/09/30 02:27

投稿

freeair.
freeair.

スコア15

test CHANGED
File without changes
test CHANGED
@@ -70,11 +70,65 @@
70
70
 
71
71
  public String myListSet() {
72
72
 
73
- myTestAccess access = new myTestAccess(getDbAccessInfo());
73
+ MyTestAccess access = new MyTestAccess(getDbAccessInfo());
74
74
 
75
75
  myList = access.selectMyList(searchbox); //DBからsearchboxが一致するレコードを取得する
76
76
 
77
- return = "execute"; //画面(jsp)を再表示する
77
+ return "execute"; //画面(jsp)を再表示する
78
+
79
+ }
80
+
81
+
82
+
83
+ //MyTestAccessクラス
84
+
85
+ public ArrayList<MyTestEntity> selectMyList(String search) {
86
+
87
+ StringBuffer stringBuffer = new StringBuffer();
88
+
89
+ stringBuffer.append("SELECT itemName");
90
+
91
+ stringBuffer.append(" ,itemStatus1");
92
+
93
+ stringBuffer.append(" ,itemStatus2");
94
+
95
+ stringBuffer.append(" ,FROM MY_TEST_TABLE");
96
+
97
+ stringBuffer.append(" WHERE itemName = ");
98
+
99
+ stringBuffer.append(search);
100
+
101
+ String sql = stringBuffer.toString();
102
+
103
+ logger.sqllog(sql);
104
+
105
+ MyTestEntity record = null;
106
+
107
+ ArrayList<MyTestEntity> ret = new ArrayList<MyTestEntity>();
108
+
109
+ try{
110
+
111
+ stmt = getConn().createStatement();
112
+
113
+ result = stmt.executeQuery(sql);
114
+
115
+ while(result.next()) {
116
+
117
+ record = new MyTestEntity();
118
+
119
+ record.setItemName(result.getString("itemName"));
120
+
121
+ record.setItemStatus1(result.getString("itemStatus1"));
122
+
123
+ record.setItemStatus2(result.getString("itemStatus2"));
124
+
125
+ ret.add(record);
126
+
127
+ }
128
+
129
+ }
130
+
131
+ return ret;
78
132
 
79
133
  }
80
134