看板 java 關於我們 聯絡資訊
※ 引述《longlyheart (longlyheart)》之銘言: : : public String doSearch(String dbName){ : : StringBuffer output=new StringBuffer(); : : /* do connection */ : : String comSQL = "SELECT * FROM articledb WHERE articlename : : like'%"+dbname+" : : while( /* expression */ ){ : : /* do something */ : : output.append( /* HTML tag with data */); : : } : : .............. : : return output.toString(); : : } 上面已經給你一種方向了,你引了他的言 至少也給人家一點回音,說說你對他這個解法的看法 真的是... 感覺就是把別人的好心回答直接無視... 至少人家的解法是可解的(漂亮與否就是另話) : public class connectBean{ : private int atSn; : private String atName = null; : private String atSize = null; : private int atPrice; : private String atPicture = null; : private String atNotice = null; : private String atClass = null; 預設都是 null,以後可以不用打後半段了。 : //資料庫控制 : public void setdbControl(String dbname){ : try{ : //建立Statement物件 : stmt = conn.createStatement(); : //執行查詢 : comSQL = "SELECT * FROM articledb WHERE articlesn like'%"+dbname+"%';"; : rs = stmt.executeQuery(comSQL); : //讀取資料 : while(rs.next()){ ^^^^^^^^^^^^^^^^^ [嘆氣] 果然不出所料... [炸] 這跟 JavaBean 一點關係也沒有 麻煩請先搞清楚上面這段程式碼再幹麼 ([小聲] tONYq,你也別一直當好人阿... 怎麼都不對我當好人...) : atSn = rs.getInt("articlesn"); : atName = rs.getString("articlename"); : atSize = rs.getString("size"); : atPrice = rs.getInt("price"); : atPicture = rs.getString("picture"); : atNotice = rs.getString("notice"); : atClass = rs.getString("class"); : } : 之前的PO文如果引起大大們的不悅,在此致上十二萬分的歉意,請原諒..(磕頭) : 這隻Bean我不知道要怎麼改才能讓使用的網頁收到全部的查詢結果,請大大指教 這年頭適度引言快要變成一種美德了... -- 侃侃長論鮮窒礙 首頁:http://www.psmonkey.idv.tw 眾目睽睽無心顫 Blog:http://ps-think.blogspot.com 煢居少聊常人事 殺頭容易告白難 歡迎參觀 Java 版(@ptt.cc)精華區 \囧/ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.228.193.189