




免費(fèi)預(yù)覽已結(jié)束,剩余1頁可下載查看
下載本文檔
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(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語句寫法?本人設(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é)貼信息。現(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. 人人文庫(kù)網(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 婚前個(gè)人資產(chǎn)分割與婚后共同財(cái)產(chǎn)規(guī)劃協(xié)議
- 再婚夫婦共同財(cái)產(chǎn)管理與婚內(nèi)忠誠(chéng)協(xié)議書
- 建筑行業(yè)人力資源配置與績(jī)效評(píng)估合同
- 健身房教練職業(yè)發(fā)展路徑規(guī)劃合同
- 餐飲業(yè)衛(wèi)生安全標(biāo)準(zhǔn)補(bǔ)充協(xié)議
- 智能家居系統(tǒng)升級(jí)改造與售后保障服務(wù)合同
- 風(fēng)力發(fā)電設(shè)備維護(hù)與風(fēng)力資源利用補(bǔ)充合同
- 社區(qū)衛(wèi)生服務(wù)中心公共衛(wèi)生信息平臺(tái)建設(shè)與運(yùn)營(yíng)服務(wù)協(xié)議
- 校招銷售崗筆試題目及答案
- 校招線上測(cè)試題庫(kù)及答案
- 從業(yè)人員健康及衛(wèi)生管理制度
- 德陽市綿竹市2023年三下數(shù)學(xué)期末含解析
- 2023年福建省福州市八縣一中聯(lián)考高一化學(xué)第二學(xué)期期末達(dá)標(biāo)測(cè)試試題含解析
- 醫(yī)學(xué)專題-呼吸困難識(shí)別、處理與轉(zhuǎn)運(yùn)原則
- 管理英語3課件
- 七年級(jí)-體育與健康基礎(chǔ)知識(shí)考核試題
- 同濟(jì)大學(xué)實(shí)驗(yàn)報(bào)告封面
- 《醫(yī)學(xué)影像診斷學(xué)》分章節(jié)試題庫(kù)含答案大全
- 申根簽證申請(qǐng)表
- 知識(shí)點(diǎn)一RLC串聯(lián)電路的電壓關(guān)系
- 淘寶運(yùn)營(yíng)轉(zhuǎn)正考試題及答案
評(píng)論
0/150
提交評(píng)論