src/com/inloam/common/BaseDAO.java

(开头部分) 7KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

package com.inloam.common;

import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public  class BaseDAO {

	private Connection  connection;

	private String tableName;
	
	
	private Sql sql;
	

	
	public void saveOrUpdate(Map bean,Connection  conn,String tableName) {
		Map obj = findbyId((String)bean.get("id"), tableName, conn);
		if(obj == null)
			save(bean, conn, tableName);
		else
			update(bean, conn, tableName);
	}

	public void update(Map bean,Connection  conn,String tableName) {
		String id = bean.get("id").toString();
		bean.remove("id");
		sql = new Sql(tableName);
		String colunm[] = sql.getColunm(bean);
		String updateSql = sql.getUpdateSql(colunm);
		System.out.println(updateSql);
		PreparedStatement pst = null;
		try {
			pst = conn.prepareStatement(updateSql);
			buldPrepareStatement(bean, colunm, pst);
			pst.setString(colunm.length+1,id);
			pst.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				if(pst != null)
					pst.close();
				if(conn != null)
					conn.close();
后面还有 237 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。