




免費(fèi)預(yù)覽已結(jié)束,剩余1頁可下載查看
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(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)要對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ì)者幫忙,謝謝! 對我有用0丟個(gè)板磚0引用舉報(bào)管理TOP 回復(fù)次數(shù):11 bea_java(灰常)等級:#1樓 得分:10回復(fù)于:2009-08-09 23:41:36如果你用了hibernate就設(shè)置級聯(lián)刪除如果沒有用hibernate 就需要 寫n條sql語句了,先刪除子表,然后刪除主表內(nèi)容,不過這個(gè)要注意使用事務(wù)去處理。對我有用0丟個(gè)板磚0引用舉報(bào)管理TOP精華推薦:【投票】對于達(dá)到一定結(jié)貼率的樓主【不】在使用【機(jī)器人】提示其結(jié)貼信息?,F(xiàn)征求大家的意見 bea_java(灰常)等級:#1樓 得分:10回復(fù)于:2009-08-09 23:41:36如果你用了hibernate就設(shè)置級聯(lián)刪除如果沒有用hibernate 就需要 寫n條sql語句了,先刪除子表,然后刪除主表內(nèi)容,不過這個(gè)要注意使用事務(wù)去處理。對我有用0丟個(gè)板磚0引用舉報(bào)管理TOP精華推薦:【投票】對于達(dá)到一定結(jié)貼率的樓主【不】在使用【機(jī)器人】提示其結(jié)貼信息?,F(xiàn)征求大家的意見zl3450341(東走西顧)等級: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等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(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ǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024六年級英語上冊教學(xué)設(shè)計(jì)
- 2025年中國旅游代理與合作伙伴間的合作合同
- 邵陽高三地理試卷及答案
- 三中高一試卷及答案
- 2025停車場租賃合同模板
- 經(jīng)濟(jì)型酒店品牌危機(jī)應(yīng)對策略考核試卷
- 稻谷加工與糧食質(zhì)量標(biāo)準(zhǔn)制定考核試卷
- 照明工程的電氣設(shè)備選型與應(yīng)用考核試卷
- 電子傳感器與檢測技術(shù)考核試卷
- 2025住宅設(shè)計(jì)與裝修合同示范文本
- 工 程 量 確 認(rèn) 單
- 2022山東高考語文答題卡(新高考I卷)word版3
- 2021年上海市工業(yè)技術(shù)學(xué)校教師招聘試題及答案解析
- 重力式降落救生艇的降落和釋放裝置課件
- 偏頭痛PPT課件(PPT 43頁)
- 工程管理專業(yè)畢業(yè)論文——施工組織設(shè)計(jì)
- 初中物理全冊知識(shí)點(diǎn)總結(jié)(教科版)
- 神經(jīng)病學(xué)緒論英文課件
- 工廠個(gè)人簡歷登記表格
- 用友U8數(shù)據(jù)字典
- 化工概論:典型化工工藝
評論
0/150
提交評論