




免費(fèi)預(yù)覽已結(jié)束,剩余1頁可下載查看
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
如:A表中有 a1,b1,c1,a2 四個(gè)字段,B表中有b1,b2,兩個(gè)字段,C表中有c1,c2兩個(gè)字段,a1,b1,c1分別為 A,B,C表的主鍵,現(xiàn)要對(duì)A表進(jìn)行增、刪、改,sql語句寫法?本人設(shè)計(jì)時(shí)考慮時(shí),遇到的第一個(gè)問題:a1為A的ID,a2為其名字,b1、c1為B、C的ID,b2,c2為名字,界面設(shè)計(jì)時(shí)把b1,c1字段都設(shè)計(jì)為下拉框,但現(xiàn)在我遇到的表B中字段特別多,如果都設(shè)計(jì)為下拉框,半個(gè)屏幕都成了下拉框,以及后臺(tái)操作用的sql語句也不知道怎么寫?會(huì)者幫忙,謝謝! 對(duì)我有用0丟個(gè)板磚0引用舉報(bào)管理TOP 回復(fù)次數(shù):11 bea_java(灰常)等級(jí):#1樓 得分:10回復(fù)于:2009-08-09 23:41:36如果你用了hibernate就設(shè)置級(jí)聯(lián)刪除如果沒有用hibernate 就需要 寫n條sql語句了,先刪除子表,然后刪除主表內(nèi)容,不過這個(gè)要注意使用事務(wù)去處理。對(duì)我有用0丟個(gè)板磚0引用舉報(bào)管理TOP精華推薦:【投票】對(duì)于達(dá)到一定結(jié)貼率的樓主【不】在使用【機(jī)器人】提示其結(jié)貼信息?,F(xiàn)征求大家的意見 bea_java(灰常)等級(jí):#1樓 得分:10回復(fù)于:2009-08-09 23:41:36如果你用了hibernate就設(shè)置級(jí)聯(lián)刪除如果沒有用hibernate 就需要 寫n條sql語句了,先刪除子表,然后刪除主表內(nèi)容,不過這個(gè)要注意使用事務(wù)去處理。對(duì)我有用0丟個(gè)板磚0引用舉報(bào)管理TOP精華推薦:【投票】對(duì)于達(dá)到一定結(jié)貼率的樓主【不】在使用【機(jī)器人】提示其結(jié)貼信息?,F(xiàn)征求大家的意見zl3450341(東走西顧)等級(jí):2#2樓 得分:0回復(fù)于:2009-08-09 23:56:24beanJava codepackage org.bean;public class FligthInfo private int flightId; private String fligthNo; private String fligthTime; private String fligthPrice; private int corporationId; /B表字段 private String corporationName; /B表字段 public int getFlightId() return flightId; public void setFlightId(int flightId) this.flightId = flightId; public String getFligthNo() return fligthNo; public void setFligthNo(String fligthNo) this.fligthNo = fligthNo; public String getFligthTime() return fligthTime; public void setFligthTime(String fligthTime) this.fligthTime = fligthTime; public String getFligthPrice() return fligthPrice; public void setFligthPrice(String fligthPrice) this.fligthPrice = fligthPrice; public int getCorporationId() return corporationId; public void setCorporationId(int corporationId) this.corporationId = corporationId; public String getCorporationName() return corporationName; public void setCorporationName(String corporationName) this.corporationName = corporationName; DAOJava codepackage org.dao;import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.ArrayList;import org.bean.FligthInfo;import org.util.ConDB;public class FligthDao /查 public ArrayList findAllFligth() ArrayList fligthList =new ArrayList(); Connection con=ConDB.getConnection(); String sql=select * from T_flight a,T_corporation b where a.corporation_Id=b.corporation_Id; System.out.println(sql); Statement stm=null; ResultSet rs=null; try stm=con.createStatement(); rs=stm.executeQuery(sql); while(rs.next() FligthInfo fligth=new FligthInfo(); fligth.setCorporationId(rs.getInt(corporation_Id); fligth.setCorporationName(rs.getString(corporation_name); fligth.setFlightId(rs.getInt(flight_Id); fligth.setFligthNo(rs.getString(flight_no); fligth.setFligthPrice(rs.getString(price); fligth.setFligthTime(rs.getString(flight_time); fligthList.add(fligth); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); finally ConDB.closeRs(rs); ConDB.closeStm(stm); ConDB.closeCon(con); return fligthList; /增 public int insertFligth(FligthInfo fligth) int flag=-1; Connection con=ConDB.getConnection(); String sql=insert into T_flight values(+fligth.getFligthNo()+,+fligth.getFligthTime()+,+fligth.getFligthPrice()+,+fligth.getCorporationId()+); System.out.println(sql); Statement stm=null; try stm=con.createStatement(); flag=stm.executeUpdate(sql); catch (SQLException e) / TODO Auto-generated catch block e.printStackTrace(); finally ConDB.closeStm(stm); ConDB.closeCon(con); return flag; servlet 添加數(shù)據(jù)Java codepackage org.service;import java.io.IOException;import java.io.PrintWriter;import java.util.ArrayList;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.bean.FligthInfo;import org.dao.FligthDao;public class InsertFligth extends HttpServlet /* * The doGet method of the servlet. * * This method is called when a form has its tag value method equals to get. * * param request the request send by the client to the server * param response the response send by the server to the client * throws ServletException if an error occurred * throws IOException if an error occurred */ public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException FligthInfo fligth=new FligthInfo(); fligth.setFligthNo(request.getParameter(fligthNo); fligth.setFligthPrice(request.getParameter(fligthPrice); fligth.setCorporationId(Integer.parseInt(request.getParameter(corporationId); fligth.setFligthTime(request.getParameter(fligthTime); FligthDao fDao=new FligthDao(); fDao.insertFligth(fligth); request.getRequestDispatcher(/servlet/FindAllFligth).forward(request, response); /* * The doPost method of the servlet. * * This method is called when a form has its tag value method equals to post. * * param request the request send by the client to the server * param response the response send by the server
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 基于移動(dòng)醫(yī)療的2025年互聯(lián)網(wǎng)醫(yī)療平臺(tái)問診質(zhì)量控制報(bào)告
- 2025年跨文化交流能力培養(yǎng)中的跨文化溝通障礙診斷與對(duì)策報(bào)告
- 冷鏈物流溫控技術(shù)與冷鏈物流冷鏈物流物流運(yùn)輸中的應(yīng)用研究報(bào)告
- ISO15189采購申請(qǐng)表表
- 2025-2030中國袋清空機(jī)行業(yè)應(yīng)用態(tài)勢與盈利前景預(yù)測報(bào)告
- 2025-2030中國美容食品行業(yè)需求動(dòng)態(tài)及營銷前景預(yù)測報(bào)告
- 體育賽事贊助商贊助數(shù)據(jù)統(tǒng)計(jì)分析考核試卷
- 聯(lián)盟穩(wěn)定性分析考核試卷
- 智能通風(fēng)設(shè)備智能化遠(yuǎn)程監(jiān)控與維護(hù)系統(tǒng)研究考核試卷
- 鹽業(yè)企業(yè)創(chuàng)新能力評(píng)價(jià)體系構(gòu)建研究考核試卷
- 2009-2022歷年河北省公安廳高速交警總隊(duì)招聘考試真題含答案2022-2023上岸必備帶詳解版4
- 六年級(jí)信息技術(shù)下冊(cè)《走進(jìn)人工智能》優(yōu)質(zhì)課獲獎(jiǎng)?wù)n件
- 工程開工報(bào)告表
- 勞動(dòng)法課件(完整版)
- 營運(yùn)車輛智能視頻監(jiān)控系統(tǒng)管理制度范本及動(dòng)態(tài)監(jiān)控管理制度
- 完整版:美制螺紋尺寸對(duì)照表(牙數(shù)、牙高、螺距、小徑、中徑外徑、鉆孔)
- 偏頭痛PPT課件(PPT 43頁)
- (完整版)入河排污口設(shè)置論證基本要求
- 10kV架空線路施工方案
- 2022年人教版小學(xué)數(shù)學(xué)一年級(jí)下冊(cè)期中測試卷二(含答案)
- 關(guān)于恒溫恒濕項(xiàng)目裝修方案及裝修細(xì)部做法
評(píng)論
0/150
提交評(píng)論