addinfo.java

来自「对数据库中的信息进行撮合匹配」· Java 代码 · 共 72 行

JAVA
72
字号
package com.cuohe.dblic;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.cuohe.userobj.MthMathinfo;

public class AddInfo {
	public int DbInsert(ResultSet res,Connection conn)
	{
		try
		{
			//设置映射表中的字段
			GetmaxId getmaxid = new GetmaxId();
			int ID = getmaxid.getId("Mth_MatchInfo",conn);
			MthMathinfo mthinfo = new MthMathinfo();
			mthinfo.SetID(ID);
			mthinfo.SetBizId(res.getInt(1));
			mthinfo.SetOrdId(res.getString(27));			
			mthinfo.SetUserID(res.getString("UserID"));
			mthinfo.SetBizTitle(res.getString("Title"));
			mthinfo.SetKey(res.getString("Keyword"));
			mthinfo.SetBizGrp(res.getString("BizGrp"));
			mthinfo.SetBizInd(res.getString("BizInd"));
			String pubtime = res.getString("PubTime");
			if(pubtime == null)
			{
				pubtime = "";
			}
			mthinfo.SetPubTime(pubtime);
			String Areaprv = res.getString("Areaprv");
			if(Areaprv == null)
			{
				Areaprv = "";
			}
			mthinfo.SetBizAreaP(Areaprv);
			String Areacty = res.getString("Areacty");
			if(Areacty == null)
			{
				Areacty = "";
			}
			mthinfo.SetBizAreaC(Areacty);
			DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			mthinfo.SetCreateTime(df.format(new Date()));
			mthinfo.SetReadTag("0");
			mthinfo.SetResendTag("0");
			mthinfo.SetStoTag("0");
			mthinfo.SetDelTag("0");
			//向表中插值
			String sql_str = "insert into Mth_MatchInfo values(" + mthinfo.GetID() + "," + mthinfo.GetOrdId() + "," + mthinfo.GetBizId() +
							 "," + mthinfo.GetUserID() + ",'" + mthinfo.GetBizGrp() + "','" + mthinfo.GetBizInd() + "','" + mthinfo.GetBizTitle() + "','" + mthinfo.GetKey() + "','" + mthinfo.GetPubTime() + 
							 "','" + mthinfo.GetBizAreaP() + "','" + mthinfo.GetBizAreaC() + "','" + mthinfo.GetCreateTime() + 
							 "','" + mthinfo.GetReadTag() + "','" + mthinfo.GetResendTag() + "','" + mthinfo.GetStoTag() + 
							 "','" + mthinfo.GetDelTag() + "'," + 0 + ")";
			Statement stmt = conn.createStatement();
			stmt.executeUpdate(sql_str);
			stmt.close();
			return 1;
		}
		catch(Exception ex)
		{
			System.out.println("DbInsert Errmsg :" + ex);
		}
		
		return 2;
	}
}

⌨️ 快捷键说明

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