该实例主要应用情景:假如某公司用mysql当做数据库服务器,由于发现mysql数据库在运行中出现不稳定情况,针对这情况,厂家要求更换连接数据库方式,改用SQL server数据库,来满足产线高效稳定的要求,下面主要看看如何实现,设计一个统一的接口IDataAccess,将SQLServerAccess,MySQLServerAccess继承这个接口,当使用数据库Sql server,实例化SQLServerAccess,相应地,如果使用MySQL,实例化MySQLServerAccess,这就是多态。

开发环境

     开发工具:Microsoft Visual Studio 旗舰版、SQL Server 2008、MySQL

     开发环境:.NET Framework 4 Client Profile.

实现步骤

1、采用MVC思想建立框架、建立PERSON_T表格;

    首先,了解什么是MVC框架,MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写,一种软件设计典范,用于组织代码用一种业务逻辑和数据显示分离的方法,这个方法的假设前提是如果业务逻辑被聚集到一个部件里面,而且界面和用户围绕数据的交互能被改进和个性化定制而不需要重新编写业务逻辑MVC被独特的发展起来用于映射传统的输入、处理和输出功能在一个逻辑的图形化用户界面的结构中。

我在VS项目中建立一个目录如下图

建立SQL与Mysql数据库表名PERSON_T,具体见下代码:

  1. 1: USE [FMSDB]
  2. 2: GO
  3. 3:
  4. 4: /****** Object: Table [dbo].[PERSON_T] Script Date: 08/05/2013 22:40:39 ******/
  5. 5: SET ANSI_NULLS ON
  6. 6: GO
  7. 7:
  8. 8: SET QUOTED_IDENTIFIER ON
  9. 9: GO
  10. 10:
  11. 11: CREATE TABLE [dbo].[PERSON_T](
  12. 12: [ID] [nvarchar](50) NULL,
  13. 13: [NAME] [nvarchar](50) NULL,
  14. 14: [AGE] [int] NULL,
  15. 15: [POSITION] [nvarchar](50) NULL,
  16. 16: [HOMEADDRESS] [nvarchar](50) NULL,
  17. 17: [IDENTIFYNUMBER] [nvarchar](50) NULL
  18. 18: ) ON [PRIMARY]
  19. 19:
  20. 20: GO
  21. 2、主要讲讲如何实现SQLMysql数据库的切换。
  1. 首先:得采用3层架构的思想来开发程序,那我们就可以从M层(即从连接数据库层修改),无需对V层(视图层)修改。
  1. 然后:在DataGateway下建立IDataAccess.cs接口与MySQLAccess.csSQLServerAccess.csOracleDataAccess.cs类,在IDataAccess.cs接口里存放对数据库进行操作的方法。在MySQLAccess.csSQLServerAccess.csOracleDataAccess.cs中添加对数据库实际操作的方法。
  1. IDataAccess.cs类中具体代码如下:
  1. 1: using System.Data;
  1. 2:  
  1. 3: namespace ListBoxUnit1.DataGateway
  1. 4: {
  1. 5: public interface IDataAccess
  1. 6: {
  1. 7: void GetSqlConnection();
  1. 8: DataSet GetPersonData();
  1. 9: int DeleteUserInfoData(string name);
  1. 10: DataSet GetUserByName(string name);
  1. 11: DataSet GetUserByIdentifyNumber(string identifyNumber);
  1. 12:  
  1. 13: bool UpdateUserByName(string Id, string Name, string Age, string Postion, string Address,
  1. 14: string IdentifyNumber);
  1. 15:  
  1. 16: bool InsertUserInfo(string Id, string Name, string Age, string Postion, string Address,
  1. 17: string IdentifyNumber);
  1. 18: }
  1. 19: }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

  1.  
  1. SQLServerAccess.cs类中具体代码如下:
  1. 1: using System;
  1. 2: using System.Data;
  1. 3: using System.Data.SqlClient;
  1. 4:  
  1. 5: namespace ListBoxUnit1.DataGateway
  1. 6: {
  1. 7: class SQLServerAccess : IDataAccess
  1. 8: {
  1. 9: private string connectString;
  1. 10:  
  1. 11: private SqlConnection sqlConnection;
  1. 12:  
  1. 13: public SQLServerAccess(string dbConnString)
  1. 14: {
  1. 15: connectString = dbConnString;
  1. 16: GetSqlConnection();
  1. 17: }
  1. 18:  
  1. 19: #region IDataAccess 成员
  1. 20:  
  1. 21: public void GetSqlConnection()
  1. 22: {
  1. 23: SqlConnection conn = new SqlConnection(connectString);
  1. 24: sqlConnection = conn;
  1. 25: conn.Open();
  1. 26: }
  1. 27:  
  1. 28: public DataSet GetPersonData()
  1. 29: {
  1. 30: DataSet ds = new DataSet();
  1. 31: string sqlText = @"SELECT * FROM PERSON_T order by ID ;";
  1. 32: try
  1. 33: {
  1. 34: //SqlConnection conn = GetSqlConnection();
  1. 35: SqlCommand sqlCommand = sqlConnection.CreateCommand();
  1. 36: sqlCommand.CommandText = sqlText;
  1. 37: sqlCommand.CommandType = CommandType.Text;
  1. 38: SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
  1. 39: sqlDataAdapter.Fill(ds);
  1. 40: }
  1. 41: catch (Exception ex)
  1. 42: {
  1. 43: Console.WriteLine(ex.Message);
  1. 44: }
  1. 45: return ds;
  1. 46: }
  1. 47:  
  1. 48: public int DeleteUserInfoData(string name)
  1. 49: {
  1. 50: string sqlText = @"delete FROM PERSON_T where NAME='{0}';";
  1. 51: sqlText = string.Format(sqlText, name);
  1. 52: try
  1. 53: {
  1. 54: //SqlConnection conn = GetSqlConnection();
  1. 55: SqlCommand sqlCommand = sqlConnection.CreateCommand();
  1. 56: sqlCommand.CommandText = sqlText;
  1. 57: sqlCommand.CommandType = CommandType.Text;
  1. 58: int i = sqlCommand.ExecuteNonQuery();
  1. 59: return i;
  1. 60: }
  1. 61: catch (Exception ex)
  1. 62: {
  1. 63: return 0;
  1. 64: }
  1. 65: }
  1. 66:  
  1. 67: public DataSet GetUserByName(string name)
  1. 68: {
  1. 69: DataSet ds = new DataSet();
  1. 70: string sqlText = @"SELECT * FROM PERSON_T where NAME='{0}';";
  1. 71: sqlText = string.Format(sqlText, name);
  1. 72: try
  1. 73: {
  1. 74: SqlCommand sqlCommand = sqlConnection.CreateCommand();
  1. 75: sqlCommand.CommandText = sqlText;
  1. 76: sqlCommand.CommandType = CommandType.Text;
  1. 77: SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
  1. 78: sqlDataAdapter.Fill(ds);
  1. 79: }
  1. 80: catch (Exception ex)
  1. 81: {
  1. 82: Console.WriteLine(ex.Message);
  1. 83: }
  1. 84: return ds;
  1. 85: }
  1. 86:  
  1. 87: public DataSet GetUserByIdentifyNumber(string identifyNumber)
  1. 88: {
  1. 89: DataSet ds = new DataSet();
  1. 90: string sqlText = @"SELECT * FROM PERSON_T where IDENTIFYNUMBER='{0}';";
  1. 91: sqlText = string.Format(sqlText, identifyNumber);
  1. 92: try
  1. 93: {
  1. 94: SqlCommand sqlCommand = sqlConnection.CreateCommand();
  1. 95: sqlCommand.CommandText = sqlText;
  1. 96: sqlCommand.CommandType = CommandType.Text;
  1. 97: SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
  1. 98: sqlDataAdapter.Fill(ds);
  1. 99: }
  1. 100: catch (Exception ex)
  1. 101: {
  1. 102: Console.WriteLine(ex.Message);
  1. 103: }
  1. 104: return ds;
  1. 105: }
  1. 106:  
  1. 107: public bool UpdateUserByName(string Id, string Name, string Age, string Postion, string Address, string IdentifyNumber)
  1. 108: {
  1. 109: string sqlText =
  1. 110: @"update PERSON_T set ID='{0}',NAME='{1}',AGE='{2}',POSITION='{3}',HOMEADDRESS='{4}',IDENTIFYNUMBER='{5}' FROM PERSON_T where NAME='{1}';";
  1. 111: sqlText = string.Format(sqlText, Id, Name, Age, Postion, Address, IdentifyNumber);
  1. 112: try
  1. 113: {
  1. 114: SqlCommand sqlCommand = sqlConnection.CreateCommand();
  1. 115: sqlCommand.CommandText = sqlText;
  1. 116: sqlCommand.CommandType = CommandType.Text;
  1. 117: int i = sqlCommand.ExecuteNonQuery();
  1. 118: return true;
  1. 119:  
  1. 120: }
  1. 121: catch (Exception ex)
  1. 122: {
  1. 123: return false;
  1. 124: }
  1. 125: }
  1. 126:  
  1. 127: public bool InsertUserInfo(string Id, string Name, string Age, string Postion, string Address, string IdentifyNumber)
  1. 128: {
  1. 129: string sqlText =
  1. 130: @"Insert into PERSON_T (ID,NAME,AGE,POSITION,HOMEADDRESS,IDENTIFYNUMBER)Values('{0}','{1}','{2}','{3}','{4}','{5}');";
  1. 131: sqlText = string.Format(sqlText, Id, Name, Age, Postion, Address, IdentifyNumber);
  1. 132: try
  1. 133: {
  1. 134: SqlCommand sqlCommand = sqlConnection.CreateCommand();
  1. 135: sqlCommand.CommandText = sqlText;
  1. 136: sqlCommand.CommandType = CommandType.Text;
  1. 137: int i = sqlCommand.ExecuteNonQuery();
  1. 138: return true;
  1. 139: }
  1. 140: catch (Exception ex)
  1. 141: {
  1. 142: return false;
  1. 143: }
  1. 144: }
  1. 145:  
  1. 146: #endregion
  1. 147: }
  1. 148: }
  1.  

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

  1. MySQLAccess.cs类中具体代码如下:
  2.    1:  using System;
  3.    2:  using System.Data;
  4.    3:  using MySql.Data.MySqlClient;
  5.    4:   
  6.    5:  namespace ListBoxUnit1.DataGateway
  7.    6:  {
  8.    7:      class MySQLAccess : IDataAccess
  9.    8:      {
  10.    9:          //定义连接Mysql的对象的属性
  11.   10:          private string connectString;
  12.   11:   
  13.   12:          private MySqlConnection mySqlConnection;
  14.   13:   
  15.   14:          #region IDataAccess 成员
  16.   15:   
  17.   16:          public MySQLAccess(string dbConnString)
  18.   17:          {
  19.   18:              connectString = dbConnString;
  20.   19:              GetSqlConnection();
  21.   20:          }
  22.   21:   
  23.   22:          public void GetSqlConnection()
  24.   23:          {
  25.   24:              MySqlConnection conn = new MySqlConnection(connectString);
  26.   25:              mySqlConnection = conn;
  27.   26:              conn.Open();
  28.   27:          }
  29.   28:   
  30.   29:          public DataSet GetPersonData()
  31.   30:          {
  32.   31:              DataSet ds = new DataSet();
  33.   32:              string mySqlText = @"SELECT * FROM PERSON_T order by ID ;";
  34.   33:              try
  35.   34:              {
  36.   35:                  MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
  37.   36:                  mySqlCommand.CommandText = mySqlText;
  38.   37:                  mySqlCommand.CommandType = CommandType.Text;
  39.   38:                  MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(mySqlCommand);
  40.   39:                  mySqlDataAdapter.Fill(ds);
  41.   40:              }
  42.   41:              catch (Exception ex)
  43.   42:              {
  44.   43:                  Console.WriteLine(ex.Message);
  45.   44:              }
  46.   45:              return ds;
  47.   46:          }
  48.   47:   
  49.   48:          public int DeleteUserInfoData(string name)
  50.   49:          {
  51.   50:              string mySqlText = @"delete  FROM PERSON_T where NAME='{0}';";
  52.   51:              mySqlText = string.Format(mySqlText, name);
  53.   52:              try
  54.   53:              {
  55.   54:                  MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
  56.   55:                  mySqlCommand.CommandText = mySqlText;
  57.   56:                  mySqlCommand.CommandType = CommandType.Text;
  58.   57:                  int i = mySqlCommand.ExecuteNonQuery();
  59.   58:                  return i;
  60.   59:              }
  61.   60:              catch (Exception ex)
  62.   61:              {
  63.   62:                  return 0;
  64.   63:              }
  65.   64:          }
  66.   65:   
  67.   66:          public DataSet GetUserByName(string name)
  68.   67:          {
  69.   68:              DataSet ds = new DataSet();
  70.   69:              string mySqlText = @"SELECT * FROM PERSON_T where NAME='{0}';";
  71.   70:              mySqlText = string.Format(mySqlText, name);
  72.   71:              try
  73.   72:              {
  74.   73:                  MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
  75.   74:                  mySqlCommand.CommandText = mySqlText;
  76.   75:                  mySqlCommand.CommandType = CommandType.Text;
  77.   76:                  MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(mySqlCommand);
  78.   77:                  mySqlDataAdapter.Fill(ds);
  79.   78:              }
  80.   79:              catch (Exception ex)
  81.   80:              {
  82.   81:                  Console.WriteLine(ex.Message);
  83.   82:              }
  84.   83:              return ds;
  85.   84:          }
  86.   85:   
  87.   86:          public DataSet GetUserByIdentifyNumber(string identifyNumber)
  88.   87:          {
  89.   88:              DataSet ds = new DataSet();
  90.   89:              string mySqlText = @"SELECT * FROM PERSON_T where IDENTIFYNUMBER='{0}';";
  91.   90:              mySqlText = string.Format(mySqlText, identifyNumber);
  92.   91:              try
  93.   92:              {
  94.   93:   
  95.   94:                  MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
  96.   95:                  mySqlCommand.CommandText = mySqlText;
  97.   96:                  mySqlCommand.CommandType = CommandType.Text;
  98.   97:                  MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(mySqlCommand);
  99.   98:                  mySqlDataAdapter.Fill(ds);
  100.   99:              }
  101.  100:              catch (Exception ex)
  102.  101:              {
  103.  102:                  Console.WriteLine(ex.Message);
  104.  103:              }
  105.  104:              return ds;
  106.  105:          }
  107.  106:   
  108.  107:          public bool UpdateUserByName(string Id, string Name, string Age, string Postion, string Address, string IdentifyNumber)
  109.  108:          {
  110.  109:              string mySqlText =
  111.  110:                 @"update PERSON_T set ID='{0}',NAME='{1}',AGE='{2}',POSITION='{3}',HOMEADDRESS='{4}',IDENTIFYNUMBER='{5}'where NAME='{1}';";
  112.  111:              mySqlText = string.Format(mySqlText, Id, Name, Age, Postion, Address, IdentifyNumber);
  113.  112:              try
  114.  113:              {
  115.  114:   
  116.  115:                  MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
  117.  116:                  mySqlCommand.CommandText = mySqlText;
  118.  117:                  mySqlCommand.CommandType = CommandType.Text;
  119.  118:                  int i = mySqlCommand.ExecuteNonQuery();
  120.  119:                  return true;
  121.  120:   
  122.  121:              }
  123.  122:              catch (Exception ex)
  124.  123:              {
  125.  124:                  return false;
  126.  125:              }
  127.  126:          }
  128.  127:   
  129.  128:          public bool InsertUserInfo(string Id, string Name, string Age, string Postion, string Address, string IdentifyNumber)
  130.  129:          {
  131.  130:              string mySqlText =
  132.  131:                      @"Insert into PERSON_T (ID,NAME,AGE,POSITION,HOMEADDRESS,IDENTIFYNUMBER)Values('{0}','{1}','{2}','{3}','{4}','{5}');";
  133.  132:              mySqlText = string.Format(mySqlText, Id, Name, Age, Postion, Address, IdentifyNumber);
  134.  133:              try
  135.  134:              {
  136.  135:                  MySqlCommand mySqlCommand = mySqlConnection.CreateCommand();
  137.  136:                  mySqlCommand.CommandText = mySqlText;
  138.  137:                  mySqlCommand.CommandType = CommandType.Text;
  139.  138:                  int i = mySqlCommand.ExecuteNonQuery();
  140.  139:                  return true;
  141.  140:              }
  142.  141:              catch (Exception ex)
  143.  142:              {
  144.  143:                  return false;
  145.  144:              }
  146.  145:          }
  147.  146:   
  148.  147:          #endregion
  149.  148:      }
  150.  149:  }
  151.  
  152. .csharpcode, .csharpcode pre

  153. {

  154. font-size: small;

  155. color: black;

  156. font-family: consolas, "Courier New", courier, monospace;

  157. background-color: #ffffff;

  158. /*white-space: pre;*/

  159. }

  160. .csharpcode pre { margin: 0em; }

  161. .csharpcode .rem { color: #008000; }

  162. .csharpcode .kwrd { color: #0000ff; }

  163. .csharpcode .str { color: #006080; }

  164. .csharpcode .op { color: #0000c0; }

  165. .csharpcode .preproc { color: #cc6633; }

  166. .csharpcode .asp { background-color: #ffff00; }

  167. .csharpcode .html { color: #800000; }

  168. .csharpcode .attr { color: #ff0000; }

  169. .csharpcode .alt

  170. {

  171. background-color: #f4f4f4;

  172. width: 100%;

  173. margin: 0em;

  174. }

  175. .csharpcode .lnum { color: #606060; }

  1.  
  1. 3App.config中具体代码如下,从中屏蔽不需要的数据库代码即可:
  1. 1: <?xml version="1.0" encoding="utf-8"?>
  1. 2: <configuration>
  1. 3: <appSettings>
  1. 4: <add key="MySQLAccess.Conn" value="server=localhost;user id=root;password=12345;database=fmsdb;character set=utf8"/>
  1. 5: <!--<add key="SQLServerAccess.Conn" value="Data Source=localhost,1433;Network Library=DBMSSOCN;Initial Catalog=FMSDB;User ID=root;Password=12345;" />-->
  1. 6: <!--<add key="OracleServerAccess.Conn" value="User Id=root;Password=12345;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SID=AUTHDB)(SERVER=DEDICATED)));" />-->
  1. 7: </appSettings>
  1. 8: </configuration>
  1.  

技术点

1、主要熟练运用连接SQL与Mysql连接数据库的基本知识

2、创建接口,以及多个类继承该接口,使用多态

3、使用正则表达式和if…else if…语句,控制用户输入内容

4、面向对象编程概念进一步加深理解

疑惑

对于SQL与Mysql数据库建立连接的基本概念比较模糊,对于定义接口,多个类继承该接口的技术比较生疏。

感受

通过该实例的练习,已经对通过改配置文件,切换不同数据库有了一定的理解,另外对于程序的控制方面如if…else if…、do..while…控制语句有了一定的理解,另外对于正则表式的使用也有了比较清晰的概念,缺点在于对SQL连接以及Mysql连接概念不是很清楚,对于数据或参数的传递不熟练,不知道怎样把面向对象的概念深刻理解,望高人指点!!

源码下载

  1.  

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

C#编程连接数据库,通过更改配置文件切换数据库功能。的更多相关文章

  1. 切换数据库+ThreadLocal+AbstractRoutingDataSource 一

    最近项目用的数据库要整合成一个,所以把多源数据库切换的写法要清除掉.所以以下记载了多远数据库切换的用法及个人对源码的理解. 框架:Spring+mybatis+vertx,(多源数据库切换的用法不涉及 ...

  2. Spring3 整合Hibernate3.5 动态切换SessionFactory (切换数据库方言)

    一.缘由 上一篇文章Spring3.3 整合 Hibernate3.MyBatis3.2 配置多数据源/动态切换数据源 方法介绍到了怎么样在Sping.MyBatis.Hibernate整合的应用中动 ...

  3. 动态切换数据库(EF框架)

             文章简略:本文测试项目为Silverlight+EF+RIA Service动态切换数据库的问题 通常,Ado.net EntityFramework的数据库连接字符串Connect ...

  4. Django框架之第二篇--app注册、静态文件配置、form表单提交、pycharm连接数据库、django使用mysql数据库、表字段的增删改查、表数据的增删改查

    本节知识点大致为:静态文件配置.form表单提交数据后端如何获取.request方法.pycharm连接数据库,django使用mysql数据库.表字段的增删改查.表数据的增删改查 一.创建app,创 ...

  5. spring boot 配置文件加密数据库用户名/密码

    这篇文章为大家分享spring boot的配置文件properties文件里面使用经过加密的数据库用户名+密码,因为在自己做过的项目中,有这样的需求,尤其是一些大公司,或者说上市公司,是不会把这些敏感 ...

  6. Phalcon如何切换数据库《Phalcon入坑指南系列 三》

    本系列目录 一.Phalcon在Windows上安装 <Phalcon入坑指南系列 一> 二.Phalcon入坑必须知道的功能(项目配置.控制器.模型.增.删.改.查) 三.Phalcon ...

  7. (转)PHP连接数据库之PHP连接MYSQL数据库代码

    PHP连接数据库之PHP连接MYSQL数据库代码 < ?php $mysql_server_name='localhost'; //改成自己的mysql数据库服务器 $mysql_usernam ...

  8. hibernate通过配置文件生成数据库信息

    hibernate可以通过配置文件在数据库生成相应的数据库信息.也可以把数据库的信息生成相应的代码(实体类操作类和映射文件) 下面是通过代码默认对hibernate.cfg.xml信息在数据库生成信息 ...

  9. Linux学习——shell编程之环境变量配置文件

    小白学习,在学习中总结! shell编程之环境变量配置文件 一:环境变量配置文件 1 shell编程之环境变量配置 变量类型: 用户自定义变量(本地变量) 环境变量 :定义每个用户的操作环境,如pat ...

随机推荐

  1. HDOJ 2010 水仙花数

    Problem Description 春天是鲜花的季节,水仙花就是其中最迷人的代表,数学上有个水仙花数,他是这样定义的: "水仙花数"是指一个三位数,它的各位数字的立方和等于其本 ...

  2. SRM 387(1-250pt)

    DIV1 300pt 题意:有m种颜色的球若干个放在n个盒子里.每次操作可从一个盒子里拿出任意个球(不必同色),放进另一个盒子.要求终态为:1.最多有一个盒子里面装有不同色的球,该盒子成为joker ...

  3. linux 内核驱动加载过程中 向文件系统中的文件进行读写操作

    utils.h 文件: #ifndef __UTILS_H__ #define __UTILS_H__ void a2f(const char *s, ...); #endif utils.c 文件: ...

  4. HIBERNATE 01

    2017年1月8日 {LJ?Dragon}[标题]Hibernate基础知识简介_01 {LJ?Dragon}[Links]Hibernate注解详解 {LJ?Dragon}[Daily]特种部队2, ...

  5. C#类型 分类: C# 2015-03-09 08:44 202人阅读 评论(0) 收藏

    C# 类型 引言 本文之初的目的是讲述设计模式中的 Prototype(原型)模式,但是如果想较清楚地弄明白这个模式,需要了解对象克隆(Object Clone),Clone其实也就是对象复制.复制又 ...

  6. 未能正确加载“visual C++ package”包

    早上打开360要卸载软件,跳出说系统修复,习惯性的点击修复,结果修复后发现打开vs2012提示“未能正确加载“visual C++ package”包……..”, 重启也一样,google了下,是因为 ...

  7. php开发工具zendstudio13破解补丁

    io?  Intelligent Code Editor Robust Debugging Capabilities Eclipse Ecosystem Mobile: AngularJS, Ioni ...

  8. HTML5事件——contextmenu 隐藏鼠标右键菜单

    在window中单击右键或在Mac中Ctrl+单击时会触发contextmenu事件,通过取消其默认动作能够提供自己定义菜单. 首先先写一个自己的菜单: <style> ul, li { ...

  9. js 解析 bytearray 成 字符串

    function bin2String(array) { return String.fromCharCode.apply(String, array); } var bit=[104,101,108 ...

  10. hdu 2222 Keywords Search ac自己主动机

    点击打开链接题目链接 Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja ...