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

📄 wenjianfenlei.java

📁 一个真实项目的源代码。有一个比较优秀的时间类
💻 JAVA
字号:
package com.zx.dangangl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.work.db.DbConnection;
import com.work.db.DbUtil;
import com.work.exception.OurException;

public class WenJianFenLei {
	private static Log log = LogFactory.getLog(WenJianFenLei.class);

	/**
	 * 文件分类批量处理程序,可以同时批量处理多个程序
	 * 
	 * @param ids
	 * @param nd
	 * @param bgqx
	 * @param fljg
	 * @param flwt
	 */
	public void wenJianFenLei(String[] ids, String[] nd, String[] bgqx,
			String[] fljg, String[] flwt) {
		String sql = "update zx_jian set nd=?,bgqx=?,jg=?,wt=? where id=?";
		Connection conn = DbConnection.getConn();
		if (conn == null)
			throw new OurException("获取数据库连接失败!");
		PreparedStatement pst = null;
		int LEN = ids.length;
		try {
			conn.setAutoCommit(false);
			pst = conn.prepareStatement(sql);
			for(int i=0;i<LEN;i++){
				pst.setString(1,nd[i]);
				pst.setString(2,bgqx[i]);
				if(fljg[i].equals("")){
					pst.setInt(3,0);
				}else{
					pst.setInt(3,Integer.parseInt(fljg[i]));
				}
				if(flwt[i].equals("")){
					pst.setInt(4,0);
				}else{
					pst.setInt(4,Integer.parseInt(flwt[i]));
				}
				pst.setInt(5,Integer.parseInt(ids[i]));
				pst.executeUpdate();
			}
			
			conn.commit();
			log.info("文件分类处理成功!");
		} catch (SQLException e) {
			log.error("文件分类失败!",e);
			try {
				conn.rollback();
			} catch (SQLException e1) {
				e1.printStackTrace();
			}
			throw new OurException("文件分类失败!",e);
		} finally {
			DbUtil.closeStatement(pst);
			DbUtil.closeConnection(conn);
		}
	}
}

⌨️ 快捷键说明

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