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

📄 dbhelper.java

📁 sso呵呵
💻 JAVA
字号:
package com.mdcl.mocha.jlcmcc.dbhelper;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import com.mdcl.mocha.jlcmcc.DBconnection.DBConnectionManager;

/**
 * <strong>Title : DBHelper<br>
 * </strong> <strong>Description : </strong><br>
 * <strong>Create on : 2007-9-26<br>
 * </strong>
 * <p>
 * <strong>Copyright (C) Mocha Software Co.,Ltd.<br>
 * </strong>
 * <p>
 *
 * @author linda linda@mochasoft.com.cn<br>
 * @version <strong>吉林移动BPM一期</strong><br>
 *          <br>
 *          <strong>修改历史:</strong><br>
 *          修改人 修改日期 修改描述<br>
 *          -------------------------------------------<br>
 *          <br>
 *          <br>
 */
public class DBHelper {

	/**
	 * 方法描述
	 *
	 * 数据操作:添加、删除、更新等数据操作语言的共用方法
	 *
	 * @param sql
	 *            要执行的SQL语句
	 * @return true:操作成功;false:操作失败
	 */
	public static boolean dataManipulation(String sql) {
		DBConnectionManager db = null;
		Connection conn = null;
		Statement stmt = null;
		try {
			db = DBConnectionManager.getInstance();
			conn = db.getConnection("idb");
			if (conn == null)
				return false;
			stmt = conn.createStatement();
			if (stmt == null)
				return false;
			stmt.executeUpdate(sql);
		} catch (SQLException e) {
			return false;
		} finally {
			if (stmt != null) {
				try {
					stmt.close();
				} catch (SQLException e) {
					return false;
				}
			}
			db.freeConnection("idb", conn);
		}
		return true;
	}

	/**
	 * 方法描述
	 *
	 * 为字符串添加单引号,使之符合SQL语句的规范
	 *
	 * @param value
	 *            需检验的字符串
	 * @return 符合SQL语句规范的字符串
	 */
	public static String checkString(String value) {
		if (!checkNone(value))
			return "'" + value + "'";
		return "''";
	}

	/**
	 * 方法描述
	 *
	 * 判断字符串是否为空(null)或空串(“”)
	 *
	 * @param value
	 *            需检验的字符串
	 * @return false:非空串,true:空或空串
	 */
	public static boolean checkNone(String value) {
		if (value == null || value.trim().equals("")
				|| value.trim().equals("null"))
			return true;
		return false;
	}

	/**
	 * 方法描述
	 *
	 * 判断字符串是否为空(null),若是则返回一空串,否则返回原字符串
	 *
	 * @param value
	 *            需检验的字符串
	 * @return 空串或原字符串
	 */
	public static String convertNone(String value) {
		if (value == null)
			return "";
		return value;
	}

}

⌨️ 快捷键说明

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