




免費(fèi)預(yù)覽已結(jié)束,剩余1頁(yè)可下載查看
下載本文檔
版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
如: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語(yǔ)句寫(xiě)法?本人設(shè)計(jì)時(shí)考慮時(shí),遇到的第一個(gè)問(wèn)題: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語(yǔ)句也不知道怎么寫(xiě)?會(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)刪除如果沒(méi)有用hibernate 就需要 寫(xiě)n條sql語(yǔ)句了,先刪除子表,然后刪除主表內(nèi)容,不過(guò)這個(gè)要注意使用事務(wù)去處理。對(duì)我有用0丟個(gè)板磚0引用舉報(bào)管理TOP精華推薦:【投票】對(duì)于達(dá)到一定結(jié)貼率的樓主【不】在使用【機(jī)器人】提示其結(jié)貼信息?,F(xiàn)征求大家的意見(jiàn) bea_java(灰常)等級(jí):#1樓 得分:10回復(fù)于:2009-08-09 23:41:36如果你用了hibernate就設(shè)置級(jí)聯(lián)刪除如果沒(méi)有用hibernate 就需要 寫(xiě)n條sql語(yǔ)句了,先刪除子表,然后刪除主表內(nèi)容,不過(guò)這個(gè)要注意使用事務(wù)去處理。對(duì)我有用0丟個(gè)板磚0引用舉報(bào)管理TOP精華推薦:【投票】對(duì)于達(dá)到一定結(jié)貼率的樓主【不】在使用【機(jī)器人】提示其結(jié)貼信息?,F(xiàn)征求大家的意見(jià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. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中國(guó)300#溶劑油數(shù)據(jù)監(jiān)測(cè)報(bào)告
- 2025至2030年中國(guó)領(lǐng)航舵琉璃擺件市場(chǎng)分析及競(jìng)爭(zhēng)策略研究報(bào)告
- 2025至2030年中國(guó)銀色激光膜市場(chǎng)分析及競(jìng)爭(zhēng)策略研究報(bào)告
- 2025至2030年中國(guó)郵政客戶(hù)服務(wù)跟蹤系統(tǒng)市場(chǎng)分析及競(jìng)爭(zhēng)策略研究報(bào)告
- 2025至2030年中國(guó)虛擬網(wǎng)計(jì)費(fèi)卡市場(chǎng)分析及競(jìng)爭(zhēng)策略研究報(bào)告
- 2025至2030年中國(guó)耐曬品藍(lán)色淀市場(chǎng)分析及競(jìng)爭(zhēng)策略研究報(bào)告
- 2025至2030年中國(guó)磨床油霧收集處理器市場(chǎng)分析及競(jìng)爭(zhēng)策略研究報(bào)告
- 2025至2030年中國(guó)電顯組合氣扳機(jī)市場(chǎng)分析及競(jìng)爭(zhēng)策略研究報(bào)告
- 2025至2030年中國(guó)烤地瓜機(jī)市場(chǎng)分析及競(jìng)爭(zhēng)策略研究報(bào)告
- 2025至2030年中國(guó)油田加熱器市場(chǎng)分析及競(jìng)爭(zhēng)策略研究報(bào)告
- 物業(yè)公司權(quán)責(zé)手冊(cè)市場(chǎng)拓展
- 小學(xué)生小升初中自薦信5篇
- 職場(chǎng)基本功:累死你的不是工作是工作方法
- 國(guó)家開(kāi)放大學(xué)《應(yīng)用概率統(tǒng)計(jì)》綜合作業(yè)1-4參考答案
- 實(shí)驗(yàn)九 三相同步發(fā)電機(jī)的并聯(lián)運(yùn)行
- YY/T 0882-2013麻醉和呼吸設(shè)備與氧氣的兼容性
- JJG 596-2012電子式交流電能表
- GB/T 6109.1-2008漆包圓繞組線(xiàn)第1部分:一般規(guī)定
- GB/T 26121-2010可曲撓橡膠接頭
- GB/T 22184-2008谷物和豆類(lèi)散存糧食溫度測(cè)定指南
- GB/T 21650.2-2008壓汞法和氣體吸附法測(cè)定固體材料孔徑分布和孔隙度第2部分:氣體吸附法分析介孔和大孔
評(píng)論
0/150
提交評(píng)論