📄 dbnew.java~38~
字号:
package com.bwm.database;import java.sql.*;import java.util.*;import javax.servlet.http.HttpServletRequest;import com.bwm.model.New;import com.bwm.core.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: MR</p> * @author BWM * @version 1.0 */public class Dbnew extends New { private New n=new New(); public Dbnew() { } public Dbnew(String sql) { Connection con = null; PreparedStatement ps = null; ResultSet rs = null; try { con = Database.getConnection(); ps = con.prepareStatement(FinalConstants.SELECT_NEW + sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); rs = ps.executeQuery(); if (rs.next()) { n.setNid(rs.getInt("nid")); n.setUid(ParamUtils.getSqlString(rs.getString("uid"))); n.setTitle(ParamUtils.getSqlString(rs.getString("title"))); n.setNtime(ParamUtils.getSqlString(rs.getString("ntime"))); n.setFromto(ParamUtils.getSqlString(rs.getString("fromto"))); n.setContent(ParamUtils.getSqlString(rs.getString("content"))); } } catch (SQLException e) { System.out.println(e.getMessage()); e.printStackTrace(); } finally { System.out.println(ps + " Dbnew(String sql) " + n.getNid()); try { if (ps != null) { ps.close(); ps = null; } } catch (SQLException e) { ps = null; } try { if (con != null) { con.close(); con = null; } } catch (SQLException e) { con = null; } } } public Dbnew(HttpServletRequest request) { n.setUid(ParamUtils.getRequestString(request, "uid")); n.setTitle(ParamUtils.getRequestString(request, "title")); n.setFromto(ParamUtils.getRequestString(request, "from")); n.setContent(ParamUtils.getRequestString(request, "content")); } public boolean Insert() { boolean b = false; Connection con = null; PreparedStatement ps = null; try { con = Database.getConnection(); ps = con.prepareStatement(FinalConstants.INSERT_AFFICHE); ps.setString(1, a.getUid()); ps.setString(2, a.getTitle()); ps.setString(3, a.getContent()); if (ps.executeUpdate() > 0) { b = true; } else { b = false; } } catch (SQLException e) { b = false; System.out.println(e.getMessage()); e.printStackTrace(); } finally { System.out.println(ps + " Dbaffiche.Insert()"); try { if (ps != null) { ps.close(); } } catch (SQLException e) { ps = null; } try { if (con != null) { con.close(); } } catch (SQLException e) { con = null; } } return b; } public int getNid() { return n.getNid(); } public void setNid(int nid) { n.setNid(nid); } public String getUid() { return n.getUid(); } public void setUid(String uid) { n.setUid(uid); } public String getNtime() { return n.getNtime(); } public void setNtime(String ntime) { n.setNtime(ntime); } public String getFromto() { return n.getFromto(); } public void setFromto(String fromto) { n.setFromto(fromto); } public String getContent() { return n.getContent(); } public void setContent(String content) { n.setContent(content); } public String getTitle() { return n.getTitle(); } public void setTitle(String title) { n.setTitle(title); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -