⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 downloadcommentado.java

📁 辅助办公系统,具有发布公告、站内邮箱、日程安排、日志查看等功能
💻 JAVA
字号:
package com.x3408.download;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

import com.x3408.database.CNProvider;

public class DownLoadCommentADO {

	public static boolean commentInsert(CommentInfo commentInfo){
		Connection conn=CNProvider.getConnection();
		PreparedStatement pstat=null;
		if(commentInfo.isValid()){
			try {
				pstat=conn.prepareStatement("insert downLoadComment(fileID,comment,commenter,commentPubTime)values(?,?,?,?)");
				pstat.setInt(1, commentInfo.getFileID());
				pstat.setString(2, commentInfo.getComment());
				pstat.setString(3, commentInfo.getCommenter());
				pstat.setString(4, commentInfo.getCommentPubTime());
				pstat.executeUpdate();
				return true;
			} catch (SQLException e) {
				// TODO 自动生成 catch 块
				e.printStackTrace();
			}
		}
		return false;
	}
	public static boolean commentDelete(String fieldName,String pFieldValue){
		Connection conn=CNProvider.getConnection();
		PreparedStatement pstat=null;
		if(pFieldValue!=null&&!"".equals(pFieldValue.trim())){
			int fieldValue=Integer.parseInt(pFieldValue.trim());
			try {
				pstat=conn.prepareStatement("delete from downLoadComment where "+fieldName+"=?");
				pstat.setInt(1, fieldValue);
				pstat.executeUpdate();
				return true;
			} catch (SQLException e) {
				// TODO 自动生成 catch 块
				e.printStackTrace();
			}
		}
		return false;
	}

	public static Vector allCommentQuery(String pFileID){
		Connection conn=CNProvider.getConnection();
		ResultSet rs=null;
		PreparedStatement pstat=null;
		Vector<CommentInfo> commentList=new Vector<CommentInfo>();
		CommentInfo commentInfo=null;
		int fileID=Integer.parseInt(pFileID);
		try {
			pstat=conn.prepareStatement("select * from downLoadComment where fileID=?");
			pstat.setInt(1, fileID);
			rs=pstat.executeQuery();
			while(rs.next()){
				commentInfo=new CommentInfo(rs.getString("commentID"),rs.getString("fileID"),
						rs.getString("comment"),rs.getString("commenter"),rs.getString("commentPubTime"));
				commentList.addElement(commentInfo);
			}
			return commentList.size()<1?null:commentList;
		} catch (SQLException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		return null;
	}
	public static CommentInfo commentQuery(String pCommentID){
		Connection conn=CNProvider.getConnection();
		PreparedStatement pstat=null;
		ResultSet rs=null;
		CommentInfo commentInfo=null;
		int commentID=Integer.parseInt(pCommentID);
		try {
			pstat=conn.prepareStatement("select * from downLoadComment where commentID=?");
			pstat.setInt(1, commentID);
			rs=pstat.executeQuery();
			if(rs.next()){
				commentInfo=new CommentInfo(rs.getString("commentID"),rs.getString("fileID"),
						rs.getString("comment"),rs.getString("commenter"),rs.getString("commentPubTime"));
			}
		} catch (SQLException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		return commentInfo;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -