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

📄 affixinfodao.java

📁 实现办公自动化系统
💻 JAVA
字号:
/**
 * 传送的文件处理类
 */

package com.oa.struts.document.modle;
import java.sql.*;

import com.oa.struts.vo.AffixInfo;
import com.oa.util.DBConn;
public class AffixInfoDAO 
{
	public Connection con=null;
	public PreparedStatement pstmt=null;
	public Statement stmt=null;
	public DBConn dbcon=null;
	public ResultSet rs=null;
	public AffixInfoDAO()
	{
		
	}
	//插入文件的信息
	public boolean insertAffixInfo(AffixInfo affixInfo)
	{
		boolean flag=false;
		dbcon=new DBConn();
		con=dbcon.getConnection();
		try
		{
			String sql="insert into tb_affix values(doc_seq.nextval-1,?,?,?,?,?)";
			pstmt=con.prepareStatement(sql);
			pstmt.setString(1, affixInfo.getAffixName());
			pstmt.setString(2, affixInfo.getDownName());
			pstmt.setString(3, affixInfo.getSavePath());
			pstmt.setLong(4, affixInfo.getSize());
			pstmt.setString(5, affixInfo.getT_ext());
			int i=pstmt.executeUpdate();
			if(i>0)
			{
				flag=true;
			}
			 con.commit();
		} catch (SQLException e) {
			
			try {
				if(con!=null)
				{
					con.rollback();//事务回滚
				}
			} catch (SQLException e1) {
				
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
		finally
		{
			try {
				if(con!=null)
				{
					con.close();
				}
				if(pstmt!=null)
				{
					pstmt.close();
				}
				if(rs!=null)
				{
					rs.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return flag;
	}

	public AffixInfo getAffixInfo(int affixId)
	{
		AffixInfo affixInfo =new AffixInfo();
		dbcon=new DBConn();
		con=dbcon.getConnection();
		try
		{
			String sql="select * from tb_affix where ID=?";
			pstmt=con.prepareStatement(sql);
			pstmt.setInt(1, affixId);
			rs=pstmt.executeQuery();
			while(rs.next())
			{
				affixInfo.setAffixName(rs.getString("AFFIXNAME"));
				affixInfo.setDownName(rs.getString("DOWNNAME"));
				affixInfo.setSavePath(rs.getString("SAVEPATH"));
				affixInfo.setSize(rs.getLong("SIZE"));
				affixInfo.setT_ext(rs.getString("T_EXT"));
			}
			 con.commit();
		} catch (SQLException e) {
			
			try {
				if(con!=null)
				{
					con.rollback();//事务回滚
				}
			} catch (SQLException e1) {
				
				e1.printStackTrace();
			}
			e.printStackTrace();
		}
		finally
		{
			try {
				if(con!=null)
				{
					con.close();
				}
				if(pstmt!=null)
				{
					pstmt.close();
				}
				if(rs!=null)
				{
					rs.close();
				}
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		
		return affixInfo;
	}
}

⌨️ 快捷键说明

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