| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 900 人关注过本帖
标题:求助```在线等~~!
只看楼主 加入收藏
从零开始
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2004-11-3
收藏
 问题点数:0 回复次数:8 
求助```在线等~~!

package xzt.rs.visualize;

// Imports import com.content.util.UserNotFoundException;

public class Mail {

// Fields private String AttachFiles; private static final String DELETE_PERMISSIONS = "DELETE FROM T_MAIL WHERE Universalid=?"; private static final String INSERT_DATA = "INSERT INTO T_MAIL(Universalid,title,content,anonymity,userid,senddate,AttachFiles) VALUES(?,?,?,?,?,?,?)"; private static final String LOAD_DATA_BY_ID = "SELECT * FROM T_MAIL WHERE Universalid=?"; private static final String LOAD_MAX = "SELECT max(Universalid) FROM T_MAIL"; private static final String SAVE_DATA = "UPDATE T_MAIL SET title=?,content=?,anonymity,userid=?,senddate=?,AttachFiles=? WHERE Universalid=?"; private String anonymity; private String content; private int id; private String senddate; private String title; private String userid;

// Constructors public Mail() { }

// Methods public String getAnonymity() { return null;} public String getAttachFiles() { return null;} public String getContent() { return null;} public int getId() { return 0;} public String getSenddate() { return null;} public String getTitle() { return null;} public String getUserid() { return null;} public void insertIntoDb() { } public void loadFromDb() throws UserNotFoundException { } public void saveToDb() { } public void setAnonymity(String s1) { } public void setAttachFiles(String s1) { } public void setContent(String s1) { } public void setId(int s1) { } public void setSenddate(String s1) { } public void setTitle(String s1) { } public void setUserid(String s1) { } }

为什么AttachFile无法插入数据库而别的都可以呢?

搜索更多相关主题的帖子: 在线 
2004-11-26 16:50
helloworld
Rank: 1
等 级:新手上路
帖 子:185
专家分:0
注 册:2004-8-27
收藏
得分:0 
你不用executeUpdate()就可以更新数据库?

2004-11-26 17:30
从零开始
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2004-11-3
收藏
得分:0 
更新数据库操作写在类里了啊~~~~
2004-11-29 09:34
从零开始
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2004-11-3
收藏
得分:0 
上面的项都可以插进去,就最后一个附件一项插不进去。
2004-11-29 09:35
从零开始
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2004-11-3
收藏
得分:0 

package xzt.rs.board;

import com.capitalnet.oa.db.*; import com.content.util.*; import com.content.model.*; import java.util.*; import java.sql.*; import java.sql.Date;

/** 公告栏发布模型 */

public class CallBoard { /** DATABASE QUERIES 数据库查询 **/ private static final String LOAD_MAX = "SELECT max(Universalid) FROM T_CALLBOARD";

private static final String LOAD_DATA_BY_ID = "SELECT * FROM T_CALLBOARD WHERE Universalid=?"; private static final String INSERT_DATA = "INSERT INTO T_CALLBOARD(Universalid,title,content,delStatus,auditingStatus,auditingUserId,addUserId,AttachFiles) VALUES(?,?,?,?,?,?,?,?)"; private static final String SAVE_DATA = "UPDATE T_CALLBOARD set title=?, content=?, delStatus=?, auditingStatus=?, auditingUserId=?, addUserId=?,AttachFiles=? WHERE Universalid=?"; private static final String DELETE_PERMISSIONS = "DELETE FROM T_CALLBOARD WHERE Universalid=?";

private int id; private String title; private String content; private String delStatus; private String auditingStatus; private String auditingUserId; private String addUserId; private String addDatetime; private String AttachFiles;

public CallBoard() { }

public int getId() { return this.id; } public void setId(int s1) { this.id=s1; } public String getTitle(){ return this.title; } public void setTitle(String s1){ this.title=s1; } public String getContent(){ return this.content; } public void setContent(String s1){ this.content=s1; } public String getDelStatus(){ return this.delStatus; } public void setDelStatus(String s1){ this.delStatus=s1; } public String getAuditingStatus(){ return this.auditingStatus; } public void setAuditingStatus(String s1){ this.auditingStatus=s1; } public String getAuditingUserId(){ return this.auditingUserId; } public void setAuditingUserId(String s1){ this.auditingUserId=s1; } public String getAddUserId(){ return this.addUserId; } public void setAddUserId(String s1){ this.addUserId=s1; } public String getAddDatetime(){ return this.addDatetime; } public void setAddDatetime(String s1){ this.addDatetime=s1; }

public String getAttachFiles() { return this.AttachFiles; } public void setAttachFiles(String s1) { this.AttachFiles=s1; }

public Date stringToDate(String dateString){ StringTokenizer dateTok=new StringTokenizer(dateString ,"-"); int year=Integer.parseInt(dateTok.nextToken()); int month=Integer.parseInt(dateTok.nextToken())-1; int day=Integer.parseInt(dateTok.nextToken()); return new java.sql.Date(new GregorianCalendar(year,month,day).getTime().getTime()); }

/** * Load the data from the database.从数据库中提取数据 */ public void loadFromDb() throws UserNotFoundException { String query; Connection con = null; PreparedStatement pstmt = null; try { con = ConnectionPool.getConnection(); ConnectionProxy conProxy =new ConnectionProxy(con,true); con = conProxy.getConnection();

query=LOAD_DATA_BY_ID; pstmt = con.prepareStatement(query); pstmt.setInt(1, id); ResultSet rs = pstmt.executeQuery(); if (!rs.next()) { throw new UserNotFoundException( "Failed to read menu " + id + " from database." ); } this.id = rs.getInt("Universalid"); this.title=rs.getString("title"); this.content=rs.getString("content"); this.delStatus=rs.getString("delStatus"); this.auditingStatus=rs.getString("auditingStatus"); this.auditingUserId=rs.getString("auditingUserId"); this.addUserId=rs.getString("addUserId"); this.addDatetime=rs.getString("addDatetime"); this.AttachFiles=rs.getString("AttachFiles");

//this.attachFiles = rs.getString("AttachFiles"); } catch( SQLException sqle ) { throw new UserNotFoundException( "Failed to read user " + id + " from database.", sqle ); } finally { try { pstmt.close(); } catch (Exception e) { e.printStackTrace(); } try { con.close(); } catch (Exception e) { e.printStackTrace(); } } }

/** * Inserts a new user record into the database.插入一个新的用户记录在数据库中 */ public void insertIntoDb() { Connection con = null; PreparedStatement pstmt = null; Statement smt=null; ResultSet rs=null; try {

con = ConnectionPool.getConnection(); ConnectionProxy conProxy =new ConnectionProxy(con,true); con = conProxy.getConnection(); con.setAutoCommit(true); smt=con.createStatement(); rs=smt.executeQuery(LOAD_MAX); if(rs.next()){ this.id=rs.getInt(1)+1; } rs.close(); smt.close(); pstmt = con.prepareStatement(INSERT_DATA); pstmt.setInt(1, id); pstmt.setString(2,title); pstmt.setString(3,content); pstmt.setString(4,delStatus); pstmt.setString(5,auditingStatus); pstmt.setString(6,auditingUserId); pstmt.setString(7,addUserId); pstmt.setString(8,AttachFiles); pstmt.executeUpdate();

} catch( SQLException sqle ) { System.err.println("Error in Menu:insertIntoDb()-" + sqle); sqle.printStackTrace(); } finally { try { pstmt.close(); } catch (Exception e) { e.printStackTrace(); } try { con.close(); } catch (Exception e) { e.printStackTrace(); } } }

/** * Save the user data to the database.保存用户数据到数据库 */ public void saveToDb() { Connection con = null; PreparedStatement pstmt = null; try { con = ConnectionPool.getConnection(); ConnectionProxy conProxy =new ConnectionProxy(con,true); con = conProxy.getConnection(); con.setAutoCommit(true);

pstmt = con.prepareStatement(SAVE_DATA); pstmt.setString(1,this.title); pstmt.setString(2,this.content); pstmt.setString(3,this.delStatus); pstmt.setString(4,this.auditingStatus); pstmt.setString(5,this.auditingUserId); pstmt.setString(6,this.addUserId); pstmt.setString(7,this.AttachFiles); pstmt.setInt(8, id); pstmt.executeUpdate();

} catch( SQLException sqle ) { System.err.println( "SQLException in Menu.java:saveToDb(): " + sqle +"你好"); sqle.printStackTrace(); } finally { try { pstmt.close(); } catch (Exception e) { e.printStackTrace(); } try { con.close(); } catch (Exception e) { e.printStackTrace(); } } }

}

2004-11-29 09:43
从零开始
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2004-11-3
收藏
得分:0 

斑竹人呢?????????????????//

[此贴子已经被helloworld于2004-11-29 11:00:43编辑过]

2004-11-29 10:34
helloworld
Rank: 1
等 级:新手上路
帖 子:185
专家分:0
注 册:2004-8-27
收藏
得分:0 
你给出来这么一大段,你对数据的操作都是一致的,其他的可以,那么按照常规,这个应该是可以的。不行的原因从你的这部分程序里我是看不太出来,你看一下tomcat的Console Monitor中有没有显示什么错误出来吧

2004-11-29 11:26
从零开始
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2004-11-3
收藏
得分:0 
AttachFiles 是附件~~~~~~就是邮件里的那个附件
2004-11-29 17:40
helloworld
Rank: 1
等 级:新手上路
帖 子:185
专家分:0
注 册:2004-8-27
收藏
得分:0 
附件里面的内容可不可以提取出来的?如果可以的话就直接将提取出来内容的存入数据库

2004-11-30 11:38
快速回复:求助```在线等~~!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019228 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved