From 95cd09eda7651c204a819ae1307b3d7c38f435f2 Mon Sep 17 00:00:00 2001 From: jinyuttt Date: Thu, 13 Dec 2018 20:23:42 +0800 Subject: [PATCH] Update readme.txt --- readme.txt | 78 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 29 deletions(-) diff --git a/readme.txt b/readme.txt index 4d29587..62a92ef 100644 --- a/readme.txt +++ b/readme.txt @@ -1,50 +1,70 @@ - HiKari使用说明 -程序初始化 - 使用配置类 + HiKari浣跨敤璇存槑 + 绋嬪簭鍒濆鍖 + ----------------------------------------------------------------------------------------------------------------- + 浣跨敤閰嶇疆绫 HikariConfig hikariConfig = new HikariConfig(); - hikariConfig.DBType = "PostgreSQL"; - hikariConfig.ConnectString = "Server = 127.0.0.1; Port = 5432; User Id = postgres; Password = 1234; Database = postgres;Pooling=true; "; + hikariConfig.DBType = "PostgreSQL"; + hikariConfig.ConnectString = "Server = 127.0.0.1; Port = 5432; User Id = postgres; Password = 1234; Database = postgres;Pooling=true; "; hikariConfig.DriverDir = "DBDrivers"; hikariConfig.DriverDLL = "XXXX.dll"; hikariConfig.DBTypeXml = "DBType.xml"; HikariDataSource hikariDataSource = new HikariDataSource(hikariConfig); + 銆嬨嬨 銆嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨 -直接使用 +鐩存帴浣跨敤 HikariDataSource hikariDataSource = new HikariDataSource(); - hikariDataSource.DBType = "PostgreSQL"; + hikariDataSource.DBType = "PostgreSQL"; hikariDataSource.ConnectString = "Server = 127.0.0.1; Port = 5432; User Id = postgres; Password = 1234; Database = postgres;Pooling=true; "; hikariDataSource.DriverDir = "DBDrivers"; hikariDataSource.DriverDLL = "XXXX.dll"; hikariDataSource.DBTypeXml = "DBType.xml"; + + + 銆嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨嬨 -配置文件(推荐方式) +閰嶇疆鏂囦欢锛堟帹鑽愭柟寮忥級 HikariConfig hikariConfig = new HikariConfig(); hikariConfig.LoadConfig("Hikari.txt"); -//也可以使用 -HikariDataSource hikariDataSource = new HikariDataSource(); - hikariDataSource.LoadConfig("Hikari.txt"); - -使用 +HikariDataSource hikariDataSource = new HikariDataSource(hikariConfig); +浣跨敤l杩炴帴 hikariDataSource.GetConnection(); - -说明:程序根据配置,会调用驱动DLL. -驱动dll查找的路径:DriverDir+ DriverDLL,所以一定要配置好。 -另外一种是,如果你没有配置,而是配置了DBType.程序将会根据DBType去查找dll名称,自动去配置DriverDLL; -DBType程序中写死了4种,见附录。 -另外会读取DBType.xml文件,获取全局配置信息。该配置文件具体信息允许你在程序中设置HikariConfig或者HikariDataSource的DBTypeXml属性。 - - -源码简说 -HikariDataSource 对外提供连接 -HikariConfig 对外配置 -HikariPool 管理操作集合,连接来源 -PoolBase 操作驱动连接,是HikariPool父类 +---------------------------------------------------------------------------------------------------------------------------- +閰嶇疆鏂囦欢璇存槑锛 +1.杩炴帴瀛楃涓插繀椤昏 +2.椹卞姩鐩綍DriverDir椤逛笉閰嶇疆鍒欎娇鐢ㄩ粯璁rivers鐩綍 +3.鍏充簬椹卞姩dll鏈2绉嶏細 + 锛1锛夌洿鎺ュ湪閰嶇疆鏂囦欢涓厤缃瓺riverDLL椤癸紝杩欎釜鏃跺欎笉闇瑕丏BType閰嶇疆椤 + 锛2锛塂BType椤瑰拰DBType.xml缁撳悎浣跨敤锛岃繖鏃朵笉闇瑕佸崟鐙湪姣忎釜杩炴帴閰嶇疆涓厤缃瓺riverDLL銆 + 杩欎釜鏃跺欒繛鎺ユ睜鏌ユ壘dll鐨勬柟寮忥細1>DBType閰嶇疆鏄粯璁ょ殑4绫伙紝鍒欐棤闇DBType.xml鏉ユ煡鎵綿ll鏂囦欢鍚嶇О銆 + 2>DBType閰嶇疆涓嶆槸榛樿鐨4绫伙紝鍒欓渶瑕丅Type.xml涓殑閰嶇疆鏉ヨ幏鍙朌LL鏂囦欢鍚嶇О銆傚洜涓虹▼搴忎笉鐭ラ亾dll. + 鍏跺疄杩2绉嶅氨鏄垎鏁d笌姹囨荤殑鍖哄埆銆傛湁鐨勪範鎯瘡涓厤缃枃浠堕厤缃甦ll,鏂逛究鐩戞祴锛涙湁鐨勪範鎯啓鍦ㄤ竴璧凤紝鏂逛究绠$悊銆傜湅鑷繁鎯呭喌銆 + DBType绋嬪簭涓啓姝讳簡4绉嶏紝瑙侀檮褰曘 + DBType.xml鎴戠О涓哄叏灞閰嶇疆鏂囦欢锛岃鍙栨椂鐨勯厤缃矾寰勫拰鍚嶇О鍙互璁剧疆HikariConfig鎴栬匟ikariDataSource鐨凞BTypeXml灞炴ц繘琛屼慨鏀癸紱榛樿灏辨槸DBType.xml + ------------------------------------------------------------------------------------------------------------------------------ + 鍗囩骇鍐呭锛 + 2018-12-13 + 1.浼樺寲鍔犺浇锛屽鍏ㄥ眬閰嶇疆鏂囦欢DBType.xml鍜岄粯璁ら」杩涜妫鏌ワ紝宸茬粡鍔犺浇杩囩殑灏变笉鍔犺浇浜嗐 + 2.鏂板杩炴帴姹犵鐞嗐傚彲浠ュ悓鏃跺惎鐢ㄥ涓繛鎺ユ睜銆傝繛鎺ユ睜浣跨敤鍜屼互鍓嶄竴鏍枫備絾鏄彲浠ュ悓鏃朵娇鐢ㄥ涓傛牴鎹厤缃枃浠跺悕绉版潵鑾峰彇涓嶅悓鐨勮繛鎺ユ睜杩炴帴銆傚彧鏄繖涓椂鍊欏彧鑳借兘澶熶娇鐢ㄩ厤缃枃浠讹紝鑰屼笉鑳藉湪浣跨敤閰嶇疆绫讳簡銆 + 杩炴帴姹犵鐞嗙被锛歁anagerPool + ManagerPool鑾峰彇杩炴帴鏃朵紶鍏ヤ竴涓悕绉帮紙閰嶇疆鏂囦欢鍚嶇О锛夋潵鑾峰彇杩炴帴锛岃繖鏃朵笉鍚岀殑閰嶇疆鍚嶇О灏辨剰鍛崇潃涓嶅悓鐨勮繛鎺ユ睜銆 + 鍙﹀璇ョ被鎻愪緵浜嗛┍鍔ㄧ洰褰曞拰鍏ㄥ眬閰嶇疆璁剧疆銆傛柟渚挎妸澶氫釜杩炴帴姹犱娇鐢ㄥ埌鐨勬墍浠LL鏀惧湪涓璧锋柟渚跨鐞嗐傝繛鎺ユ睜绠$悊绫讳笉浼氳鐩栧凡缁忓湪鍚勪釜杩炴帴姹犻厤缃枃浠堕厤缃殑 DriverDir鐩綍锛屼絾鏄疍BTypeXml灞炴т細瑕嗙洊锛屽彧鑳芥湁涓紝骞朵笖鍦ㄨ繛鎺ユ睜绠$悊绫讳腑璁剧疆銆 + 鍚屾椂鎻愪緵浜嗕娇鐢ㄧ殑杩炴帴绠$悊锛岃绠$悊鏍规嵁鑾峰彇杩炴帴鐨勭嚎绋嬩繚瀛樿繛鎺ュ璞°傚鏋滆缃簡绾跨▼鍏抽棴锛屽悓涓涓嚎绋嬭幏鍙栨柊杩炴帴锛屽垯浠ュ墠鐨勮繛鎺ュ皢浼氬叧闂備綘涔熷彲浠ュ湪鑾峰彇鐨勮繛鎺ョ殑绾跨▼涓啀娆¤幏鍙栬瀵硅薄銆 + + ------------------------------------------------------------------------------------------------------------------------ -附录 -数据库 Dll名称 说明 -Oracle Oracle.ManagedDataAccess 以前不是这个dll +婧愮爜绠璇 +HikariDataSource 瀵瑰鎻愪緵杩炴帴 +HikariConfig 瀵瑰閰嶇疆 +HikariPool 绠$悊鎿嶄綔闆嗗悎锛岃繛鎺ユ潵婧 +PoolBase 鎿嶄綔椹卞姩杩炴帴锛屾槸HikariPool鐖剁被 +鏂板锛 +ManagerPool 杩炴帴姹犵鐞嗙被 +----------------------------------------------------------------------------------------------------------------------- +闄勫綍 +鏁版嵁搴 Dll鍚嶇О 璇存槑 +Oracle Oracle.ManagedDataAccess 浠ュ墠涓嶆槸杩欎釜dll MySql MySql.Data SqlServer System PostgreSQL Npgsql