




免费预览已结束,剩余1页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
如:A表中有 a1,b1,c1,a2 四个字段,B表中有b1,b2,两个字段,C表中有c1,c2两个字段,a1,b1,c1分别为 A,B,C表的主键,现要对A表进行增、删、改,sql语句写法?本人设计时考虑时,遇到的第一个问题:a1为A的ID,a2为其名字,b1、c1为B、C的ID,b2,c2为名字,界面设计时把b1,c1字段都设计为下拉框,但现在我遇到的表B中字段特别多,如果都设计为下拉框,半个屏幕都成了下拉框,以及后台操作用的sql语句也不知道怎么写?会者帮忙,谢谢! 对我有用0丢个板砖0引用举报管理TOP 回复次数:11 bea_java(灰常)等级:#1楼 得分:10回复于:2009-08-09 23:41:36如果你用了hibernate就设置级联删除如果没有用hibernate 就需要 写n条sql语句了,先删除子表,然后删除主表内容,不过这个要注意使用事务去处理。对我有用0丢个板砖0引用举报管理TOP精华推荐:【投票】对于达到一定结贴率的楼主【不】在使用【机器人】提示其结贴信息。现征求大家的意见 bea_java(灰常)等级:#1楼 得分:10回复于:2009-08-09 23:41:36如果你用了hibernate就设置级联删除如果没有用hibernate 就需要 写n条sql语句了,先删除子表,然后删除主表内容,不过这个要注意使用事务去处理。对我有用0丢个板砖0引用举报管理TOP精华推荐:【投票】对于达到一定结贴率的楼主【不】在使用【机器人】提示其结贴信息。现征求大家的意见zl3450341(东走西顾)等级:2#2楼 得分:0回复于: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 添加数据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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年航空航天行业航空安全与空间探索研究报告
- 2025年生物技术行业生物安全技术与食品安全研究报告
- 2025年全科医学模拟临床考核答案及解析
- 2025山东潍坊市安丘市华安实业发展集团有限公司招聘2人笔试备考试题及答案解析
- 2025红河屏边县人民检察院招聘合同制书记员(2人)笔试模拟试题及答案解析
- 2025年麻醉学困难气道处理技术模拟测试卷答案及解析
- 2025巴州人民医院招聘编外聘用工作人员(3人)笔试参考题库附答案解析
- 2026中航西飞汉中航空零组件制造有限公司校园招聘笔试参考题库附答案解析
- 2025年外科围手术期并发症防范模拟考卷答案及解析
- 2025年麻醉科全麻手术中的安全控制模拟考试卷答案及解析
- 企业车辆管理系统解决方案
- 敬老院改造工作计划书
- 医院培训课件:《医务人员职业暴露与防护》
- 电梯有限空间作业方案
- J-STD-033D处理包装运输和使用湿度回流和过程敏感设备
- 诚实守信 部编版道德与法治八年级上册
- 新村卫生室人员值班表
- 子宫肌瘤手术治疗单病种质控查检表
- 物业管理项目服务报价表
- 2023年06月贵州黔西南州册亨县公开招聘事业单位工作人员(127人)笔试题库含答案解析
- 检验科生化项目SOP
评论
0/150
提交评论