/// <summary>
/// The SqlHelper class is intended to encapsulate high performance,
/// scalable best practices for common uses of SqlClient.
/// </summary>
public abstract class SqlHelper
{
/// <summary>
/// 默认密匙
/// </summary>
private const string DefaultEncryptKey = "#4d&0)-.koOeG`~x"; //Database connection strings
private static string _SQLConnString = null;
private ILog logger = LogManager.GetLogger("SQLHelper");
public static string SQLConnString
{
get
{
if (_SQLConnString == null)
{
_SQLConnString = ConfigurationManager.ConnectionStrings["WFSQLConnString"].ConnectionString;
//_SQLConnString = IBOTech.Utility.Cryptography.TripledDESDecrypt(_SQLConnString, DefaultEncryptKey);
} return _SQLConnString;
}
} // Hashtable to store cached parameters
private static Hashtable parmCache = Hashtable.Synchronized(new Hashtable()); /// <summary>
/// 生成分页SQL,仅适用于Sql Server 2005或以上版本
/// </summary>
/// <param name="startIndex">开始位置,从1开始</param>
/// <param name="endIndex">结束位置</param>
/// <param name="sql">必须以“select ”开头,以“ order by ...”结尾。</param>
/// <returns></returns>
public static string GetPagerSql(int startIndex, int endIndex, string sql)
{
//去掉“select ”
sql = sql.Remove(, ); //取order by
int index = sql.ToLower().IndexOf(" order by ");
string orderby = sql.Substring(index);
sql = sql.Remove(index); sql = "with temptbl as (SELECT ROW_NUMBER() OVER (" + orderby + ")AS Row, " + sql + ")";
sql += "\r\nSELECT * FROM temptbl where Row between " + startIndex.ToString() + " and " + endIndex.ToString(); //ILog logger = LogManager.GetLogger("SQLHelper");
//logger.Info("GetPagerSql:" + sql); ICollection<string> Categories = new List<string>() { "" }; //System.Windows.Forms.MessageBox.Show(sql);
Logger.Write("GetPagerSql:" + sql, Categories, , , TraceEventType.Error, "", "", "", "", "", null);
// Logger.Write("test saitor"); return sql;
} #region ExecuteDataset /// <summary>
/// 执行数据集
/// </summary>
/// <param name="transaction">事务</param>
/// <param name="commandType">命令类型</param>
/// <param name="commandText">命令文本</param>
/// <param name="commandParameters">参数</param>
/// <returns></returns>
public static DataSet ExecuteDataset(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
if (transaction == null) throw new ArgumentNullException("transaction");
if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction"); // Create a command and prepare it for execution
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters); SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
cmd.Parameters.Clear();
da.Dispose(); return ds;
} /// <summary>
/// 执行数据集
/// </summary>
/// <param name="connectionString">连接字符串</param>
/// <param name="cmdType">命令类型</param>
/// <param name="cmdText">sql语句</param>
/// <param name="commandParameters">参数</param>
/// <returns></returns>
public static DataSet ExecuteDataset(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(connectionString); try
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
cmd.Parameters.Clear();
da.Dispose(); return ds;
}
catch
{
throw;
}
finally
{
conn.Close();
}
} /// <summary>
/// 执行数据集
/// </summary>
/// <param name="connectionString">连接字符串</param>
/// <param name="SQLString">SQL语句</param>
/// <returns></returns>
public static DataSet ExecuteDataset(string connectionString, string SQLString)
{
using (SqlConnection conn = new SqlConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
conn.Open();
SqlDataAdapter da = new SqlDataAdapter(SQLString, conn);
da.Fill(ds, "ds");
}
catch
{
throw;
}
return ds;
}
} /// <summary>
/// 执行数据集
/// </summary>
/// <param name="conn">连接字符串</param>
/// <param name="cmdType">命令类型</param>
/// <param name="cmdText">命令文本</param>
/// <param name="commandParameters">参数</param>
/// <returns></returns>
public static DataSet ExecuteDataset(SqlConnection conn, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand();
try
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(ds);
cmd.Parameters.Clear();
da.Dispose();
}
catch
{
throw;
}
return ds;
}
#endregion ExecuteDataset /// <summary>
/// 执行SQL语句
/// </summary>
/// <param name="connectionString">连接字符串</param>
/// <param name="SQLString">SQL语句</param>
/// <returns></returns>
public static int ExecuteSql(string connectionString, string SQLString)
{
ILog logger = LogManager.GetLogger("SQLHelper");
logger.Info("ExecuteSql:" + SQLString);
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand(SQLString, connection))
{
try
{
connection.Open();
int rows = cmd.ExecuteNonQuery();
return rows;
}
catch
{
throw; }
}
}
} /// <summary>
/// 执行一条记录
/// </summary>
/// <param name="connectionString">连接字符串</param>
/// <param name="SQLString">SQL语句</param>
/// <returns></returns>
public static int ExecuteScalar(string connectionString, string SQLString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
using (SqlCommand cmd = new SqlCommand(SQLString, connection))
{
try
{
connection.Open();
int var = int.Parse(cmd.ExecuteScalar().ToString());
return var;
}
catch
{
throw; }
}
}
} /// <summary>
/// 执行多条SQL语句,实现数据库事务。
/// </summary>
/// <param name="SQLStringList">多条SQL语句</param>
public static int ExecuteSqlTran(string connectionString, List<String> SQLStringList)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
string strsql = "";
connection.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = connection;
SqlTransaction tx = connection.BeginTransaction();
cmd.Transaction = tx;
try
{
int count = ;
for (int n = ; n < SQLStringList.Count; n++)
{
strsql = SQLStringList[n];
if (strsql.Trim().Length > )
{
cmd.CommandText = strsql;
count += cmd.ExecuteNonQuery();
}
}
tx.Commit();
connection.Close();
return count;
}
catch
{
tx.Rollback();
connection.Close();
return -;
}
}
} /// <summary>
/// 一般用于父子表的插入,并且父表的主键是自增型。
/// 如果identityParam不为空,则arrCommandText[0]必须存在Identity字段,arrParam[1..n]中应该存在名为identityParam的参数
/// </summary>
/// <param name="connectionString">连接字符串</param>
/// <param name="commandType">命令类型</param>
/// <param name="arrCommandText">多条SQL语句</param>
/// <param name="arrParam">参数列表</param>
/// <param name="identityParam">null或""表示无父子关系</param>
public static void ExecuteNonQuery(string connectionString, CommandType commandType, List<string> arrCommandText, List<SqlParameter[]> arrParam, string identityParam)
{
SqlConnection connection = new SqlConnection(connectionString);
connection.Open();
SqlTransaction tran = connection.BeginTransaction();
try
{
SqlParameter[] paras;
int identityValue = ; for (int i = ; i < arrCommandText.Count; i++)
{
if (arrCommandText[i].ToString() != "")
{
paras = arrParam == null ? null : arrParam[i];
if (i > && paras != null && !string.IsNullOrEmpty(identityParam))
{
identityParam = identityParam.ToLower();
for (int j = ; j < paras.Length; j++)
{
if (paras[j].ParameterName.ToLower() == identityParam)
{
paras[j].Value = identityValue;
break;
}
}
} if (i == && !string.IsNullOrEmpty(identityParam))
{
if (commandType == CommandType.Text)
identityValue = Convert.ToInt32(ExecuteScalar(tran, commandType, (arrCommandText[i].ToLower().TrimEnd(" ;\r\n".ToCharArray()).EndsWith(" @@identity") ? arrCommandText[i] : arrCommandText[i].TrimEnd(" ;\r\n".ToCharArray()) + ";select @@IDENTITY"), paras));
else
identityValue = Convert.ToInt32(ExecuteScalar(tran, commandType, arrCommandText[i], paras));
}
else
ExecuteNonQuery(tran, commandType, arrCommandText[i], paras);
}
} tran.Commit();
}
catch (Exception e)
{
tran.Rollback();
throw e;
}
finally
{
if (connection.State == ConnectionState.Open)
connection.Close();
}
} /// <summary>
/// Execute a SqlCommand (that returns no resultset) against the database specified in the connection string
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connectionString">a valid connection string for a SqlConnection</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">the stored procedure name or T-SQL command</param>
/// <param name="commandParameters">an array of SqlParamters used to execute the command</param>
/// <returns>an int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{ SqlCommand cmd = new SqlCommand(); using (SqlConnection conn = new SqlConnection(connectionString))
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
} /// <summary>
/// Execute a SqlCommand (that returns no resultset) against an existing database connection
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="conn">an existing database connection</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">the stored procedure name or T-SQL command</param>
/// <param name="commandParameters">an array of SqlParamters used to execute the command</param>
/// <returns>an int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{ SqlCommand cmd = new SqlCommand(); PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
} /// <summary>
/// Execute a SqlCommand (that returns no resultset) using an existing SQL Transaction
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="trans">an existing sql transaction</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">the stored procedure name or T-SQL command</param>
/// <param name="commandParameters">an array of SqlParamters used to execute the command</param>
/// <returns>an int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
} /// <summary>
/// 执行一条只读记录
/// </summary>
/// <param name="trans">事务</param>
/// <param name="cmdType">命令类型</param>
/// <param name="cmdText">SQL语句</param>
/// <param name="commandParameters">参数</param>
/// <returns></returns>
public static SqlDataReader ExecuteReader(SqlTransaction trans, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
SqlDataReader rdr = cmd.ExecuteReader();
cmd.Parameters.Clear();
ICollection<string> Categories = new List<string>() { "" };
Logger.Write("ExecuteReader:" + cmdText, Categories, , , TraceEventType.Error, "", "", "", "", "", null);
return rdr;
} /// <summary>
/// 日志写
/// </summary>
/// <param name="log">用户</param>
public static void LogWriter(string log)
{
ICollection<string> Categories = new List<string>() { "" };
Logger.Write("user:" + log, Categories, , , TraceEventType.Error, "", "", "", "", "", null);
} /// <summary>
/// Execute a SqlCommand that returns a resultset against the database specified in the connection string
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// SqlDataReader r = ExecuteReader(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connectionString">a valid connection string for a SqlConnection</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">the stored procedure name or T-SQL command</param>
/// <param name="commandParameters">an array of SqlParamters used to execute the command</param>
/// <returns>A SqlDataReader containing the results</returns>
public static SqlDataReader ExecuteReader(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand();
SqlConnection conn = new SqlConnection(connectionString); // we use a try/catch here because if the method throws an exception we want to
// close the connection throw code, because no datareader will exist, hence the
// commandBehaviour.CloseConnection will not work
try
{
PrepareCommand(cmd, conn, null, cmdType, cmdText, commandParameters);
SqlDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
cmd.Parameters.Clear();
//ICollection<string> Categories = new List<string>() { "3" };
//Logger.Write("ExecuteReader:" + cmdText, Categories, 3, 0, TraceEventType.Error, "", "", "", "", "", null);
return rdr;
}
catch
{
conn.Close();
throw;
}
} /// <summary>
/// Execute a SqlCommand that returns the first column of the first record against the database specified in the connection string
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="connectionString">a valid connection string for a SqlConnection</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">the stored procedure name or T-SQL command</param>
/// <param name="commandParameters">an array of SqlParamters used to execute the command</param>
/// <returns>An object that should be converted to the expected type using Convert.To{Type}</returns>
public static object ExecuteScalar(string connectionString, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{
SqlCommand cmd = new SqlCommand(); using (SqlConnection connection = new SqlConnection(connectionString))
{
PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
object val = cmd.ExecuteScalar();
cmd.Parameters.Clear();
return val;
}
} /// <summary>
/// Execute a SqlCommand (that returns a 1x1 resultset) against the specified SqlTransaction
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int orderCount = (int)ExecuteScalar(trans, CommandType.StoredProcedure, "GetOrderCount", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="transaction">A valid SqlTransaction</param>
/// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">The stored procedure name or T-SQL command</param>
/// <param name="commandParameters">An array of SqlParamters used to execute the command</param>
/// <returns>An object containing the value in the 1x1 resultset generated by the command</returns>
public static object ExecuteScalar(SqlTransaction transaction, CommandType commandType, string commandText, params SqlParameter[] commandParameters)
{
if (transaction == null) throw new ArgumentNullException("transaction");
if (transaction != null && transaction.Connection == null) throw new ArgumentException("The transaction was rollbacked or commited, please provide an open transaction.", "transaction"); // Create a command and prepare it for execution
SqlCommand cmd = new SqlCommand();
PrepareCommand(cmd, transaction.Connection, transaction, commandType, commandText, commandParameters); // Execute the command & return the results
object retval = cmd.ExecuteScalar(); // Detach the SqlParameters from the command object, so they can be used again
cmd.Parameters.Clear();
return retval;
} /// <summary>
/// Execute a SqlCommand that returns the first column of the first record against an existing database connection
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// Object obj = ExecuteScalar(connString, CommandType.StoredProcedure, "PublishOrders", new SqlParameter("@prodid", 24));
/// </remarks>
/// <param name="conn">an existing database connection</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">the stored procedure name or T-SQL command</param>
/// <param name="commandParameters">an array of SqlParamters used to execute the command</param>
/// <returns>An object that should be converted to the expected type using Convert.To{Type}</returns>
public static object ExecuteScalar(SqlConnection connection, CommandType cmdType, string cmdText, params SqlParameter[] commandParameters)
{ SqlCommand cmd = new SqlCommand(); PrepareCommand(cmd, connection, null, cmdType, cmdText, commandParameters);
ILog logger = LogManager.GetLogger("SQLHelper");
logger.Info("ExecuteScalar:" + cmdText ); object val = cmd.ExecuteScalar();
cmd.Parameters.Clear();
return val;
} /// <summary>
/// add parameter array to the cache
/// </summary>
/// <param name="cacheKey">Key to the parameter cache</param>
/// <param name="cmdParms">an array of SqlParamters to be cached</param>
public static void CacheParameters(string cacheKey, params SqlParameter[] commandParameters)
{
parmCache[cacheKey] = commandParameters;
} /// <summary>
/// Retrieve cached parameters
/// </summary>
/// <param name="cacheKey">key used to lookup parameters</param>
/// <returns>Cached SqlParamters array</returns>
public static SqlParameter[] GetCachedParameters(string cacheKey)
{
SqlParameter[] cachedParms = (SqlParameter[])parmCache[cacheKey]; if (cachedParms == null)
return null; SqlParameter[] clonedParms = new SqlParameter[cachedParms.Length]; for (int i = , j = cachedParms.Length; i < j; i++)
clonedParms[i] = (SqlParameter)((ICloneable)cachedParms[i]).Clone(); return clonedParms;
} /// <summary>
/// Prepare a command for execution
/// </summary>
/// <param name="cmd">SqlCommand object</param>
/// <param name="conn">SqlConnection object</param>
/// <param name="trans">SqlTransaction object</param>
/// <param name="cmdType">Cmd type e.g. stored procedure or text</param>
/// <param name="cmdText">Command text, e.g. Select * from Products</param>
/// <param name="cmdParms">SqlParameters to use in the command</param>
private static void PrepareCommand(SqlCommand cmd, SqlConnection conn, SqlTransaction trans, CommandType cmdType, string cmdText, SqlParameter[] cmdParms)
{ if (conn.State != ConnectionState.Open)
conn.Open(); cmd.Connection = conn;
cmd.CommandText = cmdText; if (trans != null)
cmd.Transaction = trans; cmd.CommandType = cmdType; if (cmdParms != null)
{
foreach (SqlParameter parm in cmdParms)
cmd.Parameters.Add(parm);
}
} /// <summary>
/// 过滤通配符
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static string FmLike(string text)
{
return text.Replace("%", "[%]").Replace("_", "[_]");
}
}

c# SQLHelper总汇的更多相关文章

  1. 不该活着的SqlHelper和DBHelper

    前言: 还记得刚学ADO.NET的情景么? 还记得当年是怎么从ADO.NET被忽悠到用SqlHelper的么? 话说从入门到走上工作岗位那些年,我们就一直被纯纯地教导或引导,ADO.NET太原始,得封 ...

  2. SqlHelper中IN集合场景下的参数处理

    我手头有个古老的项目,持久层用的是古老的ADO.net.前两天去昆明旅游,其中的一个景点是云南民族村,通过导游介绍知道了一个古老的民族——基诺族,“基”在这个族内代表舅舅,“基诺”意为“跟在舅舅后边” ...

  3. 支持多返回值存储过程的SqlHelper

    public readonly string connStr = ConfigurationManager.ConnectionStrings["sql"].ConnectionS ...

  4. 微软版的SqlHelper.cs类

    一,微软SQLHelper.cs类 中文版: using System; using System.Data; using System.Xml; using System.Data.SqlClien ...

  5. 万能的SqlHelper,麻麻再也不用担心用什么数据库了

    以前只用一种数据库,倒也无所谓,但是再数据库切换的时候,发现代码差不多呀. 最初,两种数据库,大不了写两个SqlHelper,但是多了也就发现代码重用率太低了吧. 因此,下面的SqlHelper诞生了 ...

  6. sqlHelper做增删改查,SQL注入处理,存储值,cookie,session

    一.存储值 eg:登录一个页面,在进入这个页面之前你怎么知道它登没登录呢?[在登录成功之后我们把状态保存起来] 存储值得方式有两种,一种是cookie,一种是session 1.1区别: 代码: if ...

  7. sqlHelper做增删改查

    1.把数据库里面的数据显示出来 sqlHelper怎么用:[网上可以下载,需要可以找楼主要] 1.拷贝到项目,修改它的命名空间等于当前项目名称 2.数据库的连接信息,用户名,密码,登录方式等 < ...

  8. SqlHelper类

    using System; using System.Collections; using System.Collections.Generic; using System.Data; using S ...

  9. .net C# SqlHelper for Oracle

    适用于Oracle的sqlhelper 需要使用ODP.Net,引用Oracle.DataAccess.dll 推荐安装ODAC 代码如下: using System; using System.Co ...

随机推荐

  1. Android自定义组件系列【3】——自定义ViewGroup实现侧滑

    有关自定义ViewGroup的文章已经很多了,我为什么写这篇文章,对于初学者或者对自定义组件比较生疏的朋友虽然可以拿来主义的用了,但是要一步一步的实现和了解其中的过程和原理才能真真脱离别人的代码,举一 ...

  2. zxing的使用及优化

    二维码介绍 zxing项目是谷歌推出的用来识别多种格式条形码的开源项目,项目地址为https://github.com/zxing/zxing,zxing有多个人在维护,覆盖主流编程语言,也是目前还在 ...

  3. [Ramda] Eliminate Function Arguments (Point-Free Style) with Ramda's Converge

    When doing comparisons inside of functions, you end of relying heavily on the argument passed into t ...

  4. 使用CentOS7卸载自带jdk安装自己的JDK1.8

    不管在什么地方,什么时候,学习是快速提升自己的能力的一种体现!!!!!!!!!!! 关于JDK1.8 与之前的版本相比有哪些变化和新特性我也不在这详细的说明了,毕竟一度娘啥都有了,既然不多说那就直接开 ...

  5. Android网络应用之Socket(一)

    socket编程是网络通信的一个基础应用.不管是手机端还是PC端都须要socket技术来建立网络通信. 在本章小编主要从下面几个方面来介绍socket的相关知识: 各自是"什么是socket ...

  6. Mac修改文件权限:You don’t have permission to save the file

    1.从互联网上或者其他途径拿过来的工程代码,往往会报下面的提示: (1)打开文件的时候出现窗口提示You don’t have permission to save the file “project ...

  7. mysql半同步复制实现

    mysql半同步复制和异步复制的区别如上述架构图所看到的:在mysql异步复制的情况下.Mysql Master Server将自己的Binary Log通过复制线程传输出去以后,Mysql Mast ...

  8. Service熟人

    Service 为一体的四个分量间(剩余有Activity ,内容提供商,广播),它属于后台工作,能够在后台很长一段时间执行,他没有接口. 首先从使用方式上来说来说 他有两种使用方式: 1.启动式使用 ...

  9. Canvas范围裁切和几何变换

    范围裁切 clipRect() canvas.save(); canvas.clipRect(left, top, right, bottom); canvas.drawBitmap(bitmap, ...

  10. js typeof instanceof

    一般都是用typeof推断变量存在 例如if(typeof a!="undefined"){}.不是要去使用if(a)因为假定a不存在(未申报)将是错误的. 由于typeof经验n ...