dbcommonutils.java

来自「一个免费wap站」· Java 代码 · 共 57 行

JAVA
57
字号
package com.eline.wap.common.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;

import com.eline.wap.common.model.Section;
import com.eline.wap.common.util.SerializeData;
import com.eline.wap.common.util.StringUtils;

public class DBCommonUtils {

	/**
	 * 从ResultSet获取Section信息
	 * @param rst
	 * @param item
	 * @throws SQLException
	 */
	public static void populateSectionFormResultSet(ResultSet rst, Section item) throws SQLException {
		try {
			item.setIndexId(rst.getInt("IndexID"));
			item.setParentId(rst.getInt("ParentID"));
			item.setSortOrder(rst.getInt("SortOrder"));

			item.setDateCreated(StringUtils.getDate(rst.getString("DateCreated")));
			item.setLastUpdate(StringUtils.getDate(rst.getString("LastUpdate")));

			item.setActive(rst.getBoolean("IsActive"));
			item.setSearchable(rst.getBoolean("IsSearchable"));
			item.setSearchKey(rst.getString("SearchKeyWords"));

			// Serialize properties data
			item.serialize(populateSerializeDataFormResultSet(rst));

		} catch (SQLException e) {
			e.printStackTrace();
			throw e;
		}
	}
	
	/**
	 * 从ResultSet获取序列化属性数据
	 * @param rst
	 * @return
	 * @throws SQLException
	 */
	public static SerializeData populateSerializeDataFormResultSet(ResultSet rst) throws SQLException {
		SerializeData data = new SerializeData();
		try {
			data.setKeys(rst.getString("PropertyNames"));
			data.setValues(rst.getString("PropertyValues"));
		} catch (SQLException e) {
			throw e; 
		}
		return data;
	}
}

⌨️ 快捷键说明

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