public static int ExecSQL(List <string> sqls, List <object[]> parmList) { JDBBASE db = DbConnectionPool.Instance(); try { if (db != null) { try { IDBBASE vDB = (IDBBASE)db; return(vDB.ExecSQL(sqls, parmList)); } catch (Exception ex) { log4net.WriteLogFile(ex.Message, 3); return(0); } } else { log4net.WriteLogFile("获取连接对象失败", 3); return(-1); } } finally { DbConnectionPool.ReturnConnect(db); } }
public static int GetMaxID(String StrFieldName, String StrTableName) { JDBBASE db = DbConnectionPool.Instance(); try { if (db != null) { String strSQL = "SELECT MAX(" + StrFieldName + ") FROM " + StrTableName; Object objValue = db.GetStrValue(strSQL); if (objValue.Equals("")) { objValue = "0"; } return(int.Parse(objValue.ToString()) + 1); } else { log4net.WriteLogFile("获取连接对象失败", 3); return(0); } } finally { DbConnectionPool.ReturnConnect(db); } }
public static bool Exists(string strSQL) { JDBBASE db = DbConnectionPool.Instance(); try { if (db != null) { string obj = db.GetStrValue(strSQL); int iResult = obj.Equals("") ? 0 : int.Parse(obj); if (iResult > 0) { return(true); } else { return(false); } } else { log4net.WriteLogFile("获取连接对象失败", 3); return(false); } } finally { DbConnectionPool.ReturnConnect(db); } }
/// <summary> /// 释放一个活运链接 /// </summary> /// <returns></returns> public static JDBBASE Instance() { if (Connects == null) { Connects = new Queue(); } if (Connects.Count == 0) { initPool(); } try { JDBBASE mydb = (JDBBASE)Connects.Dequeue(); if ((mydb != null) && (mydb.Connectd)) { return(mydb); } else { return(Instance()); } } catch (Exception ex) { log4net.WriteLogFile(ex.Message); return(null); } }
/// <summary> /// 释放一个活运链接 /// </summary> /// <param name="AConnect"></param> public static void ReturnConnect(JDBBASE AConnect) { try { if (AConnect != null) { ActiveCount--; if (ActiveCount > iDB_MAX) { AConnect.CloseConnect(); } else { if (AConnect.Connectd) { Connects.Enqueue(AConnect); } else { AConnect = null; } } } } catch (Exception ex) { log4net.WriteLogFile("数据库连接归还失败:" + ex.Message, 3); } }
/// <summary> /// 销毁链接池 /// </summary> public static void ClearPool() { while (Connects.Count > 0) { JDBBASE row = (JDBBASE)Connects.Dequeue(); row.CloseConnect(); } ActiveCount = 0; }
public static String GetStrValue(string strSQL) { JDBBASE db = DbConnectionPool.Instance(); try { if (db != null) { return(db.GetStrValue(strSQL)); } else { log4net.WriteLogFile("G_CN:GetStrValue:获取连接对象失败", 3); return(""); } } finally { DbConnectionPool.ReturnConnect(db); } }
public static String ServerDateTime() { JDBBASE db = DbConnectionPool.Instance(); try { if (db != null) { IDBBASE myface = (IDBBASE)db; return(myface.ServerDateTime()); } else { log4net.WriteLogFile("获取连接对象失败", 3); return(null); } } finally { DbConnectionPool.ReturnConnect(db); } }
public static DataTable QueryData(string strSQL) { JDBBASE db = DbConnectionPool.Instance(); try { if (db != null) { IDBBASE vDB = (IDBBASE)db; return(vDB.Query(strSQL));; } else { log4net.WriteLogFile("获取连接对象失败", 3); return(null); } } finally { DbConnectionPool.ReturnConnect(db); } }