




免費預(yù)覽已結(jié)束,剩余1頁可下載查看
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
如:A表中有 a1,b1,c1,a2 四個字段,B表中有b1,b2,兩個字段,C表中有c1,c2兩個字段,a1,b1,c1分別為 A,B,C表的主鍵,現(xiàn)要對A表進行增、刪、改,sql語句寫法?本人設(shè)計時考慮時,遇到的第一個問題:a1為A的ID,a2為其名字,b1、c1為B、C的ID,b2,c2為名字,界面設(shè)計時把b1,c1字段都設(shè)計為下拉框,但現(xiàn)在我遇到的表B中字段特別多,如果都設(shè)計為下拉框,半個屏幕都成了下拉框,以及后臺操作用的sql語句也不知道怎么寫?會者幫忙,謝謝! 對我有用0丟個板磚0引用舉報管理TOP 回復(fù)次數(shù):11 bea_java(灰常)等級:#1樓 得分:10回復(fù)于:2009-08-09 23:41:36如果你用了hibernate就設(shè)置級聯(lián)刪除如果沒有用hibernate 就需要 寫n條sql語句了,先刪除子表,然后刪除主表內(nèi)容,不過這個要注意使用事務(wù)去處理。對我有用0丟個板磚0引用舉報管理TOP精華推薦:【投票】對于達到一定結(jié)貼率的樓主【不】在使用【機器人】提示其結(jié)貼信息?,F(xiàn)征求大家的意見 bea_java(灰常)等級:#1樓 得分:10回復(fù)于:2009-08-09 23:41:36如果你用了hibernate就設(shè)置級聯(lián)刪除如果沒有用hibernate 就需要 寫n條sql語句了,先刪除子表,然后刪除主表內(nèi)容,不過這個要注意使用事務(wù)去處理。對我有用0丟個板磚0引用舉報管理TOP精華推薦:【投票】對于達到一定結(jié)貼率的樓主【不】在使用【機器人】提示其結(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)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 通信設(shè)備招標代理合同范本
- 安全生產(chǎn)事故調(diào)查與分析咨詢服務(wù)合同
- 茶園茶葉質(zhì)量安全監(jiān)管合作協(xié)議
- 誠意金合作開發(fā)房地產(chǎn)項目保證金合同
- 大學(xué)易學(xué)考試題及答案
- 川慶井控證考試題及答案
- 建筑安全生產(chǎn)法律有哪些
- 施工現(xiàn)場安全管理獎懲辦法
- 安全生產(chǎn)費用使用范圍及明細表
- 特種設(shè)備安全監(jiān)督管理條例
- GB/T 6109.1-2008漆包圓繞組線第1部分:一般規(guī)定
- GB/T 20721-2006自動導(dǎo)引車通用技術(shù)條件
- GB/T 18948-2017內(nèi)燃機冷卻系統(tǒng)用橡膠軟管和純膠管規(guī)范
- 制藥有限公司職業(yè)衛(wèi)生管理制度
- 2022年高校教師資格證考試題庫高分通關(guān)300題a4版(浙江省專用)
- 上海國有土地上房屋征收補償協(xié)議上海住房和城鄉(xiāng)建設(shè)管理委員會
- 工程項目“三標一體”管理標準實施細則
- 完整版:美制螺紋尺寸對照表(牙數(shù)、牙高、螺距、小徑、中徑外徑、鉆孔)
- QC七大手法培訓(xùn)教材(ppt50張PPT)課件
- 中國服裝史(完整版)
- 物業(yè)服務(wù)中心架構(gòu)圖
評論
0/150
提交評論