61阅读

odbc数据源配置-Steam大数据公布出PC玩家应有的基本配置

发布时间:2017-10-17 所属栏目:jdbc连接数据库配置

一 : Steam大数据公布出PC玩家应有的基本配置

  【61阅读IT新闻频道】Steam每月都会统计游戏玩家的硬件、软件报告,最近,6月份的最新统计也出炉了,一起来看看。

  首先来了解下作为一个游戏玩家,大数据眼中基本的PC配置该是怎样。

Steam大数据公布出PC玩家应有的基本配置

PC玩家基本配置

  可以看到,Win7 64bit操作系统、8GB内存、双核CPU、英特尔HD4000显卡、1080P显示器、250GB以上的硬盘是都是个分类项中的最高,由此也描述了一个普通玩家应有的配置。

Steam大数据公布出PC玩家应有的基本配置

PC玩家基本配置

  回归到显卡子类,N系独占52%,其中保有量最高就是GTX 970,而且份额一直在增长(0.5GB显存碎碎念……);A家则是HD7900系列打头阵,这里可能涵盖了HD 7970/7950及R9 280X/280这些同核心的显卡。

Steam大数据公布出PC玩家应有的基本配置

PC玩家基本配置

  在CPU中,Intel仍然是攫取了75%的市占,留给AMD的仅有25%。双核、2.3GHz这样的U仍占主流,当然到了A家,自然起步频率就得3.3GHz走起了。

  对比一下这些大数据,各位玩家朋友们有没有拖平均数的后腿呢?

扫描二维码关注IT新闻公众平台,第一时间获取新鲜IT资讯
【请搜索微信“今天的科技新闻”加关注】

二 : WIN764位旗舰版安装OFFICE2003提示:“错误1919,配置ODBC数据源MSAcces

WIN7 64位旗舰版安装OFFICE2003 提示:“错误1919,配置ODBC数据源MS Access Database时发生错误ODEC错误”

在64位系统上,32位软件的注册表的信息不是直接在在Software下,而是在Software\Wow6432Node下才是32位软件的注册信息。
只有64位软件才是直接在Software下的。
找一台win7 32位操作系统的机器导出注册表,位置如下:
HKEY_CURRENT_USER\Software\ODBCHKEY_LOCAL_MACHINE\Software\ODBC
32位的注册导出文件,可以直接用记事本编辑文件,在Software后添加Wow6432Node。也就是:HKEY_CURRENT_USER\Software\Wow6432Node\ODBCHKEY_LOCAL_MACHINE\Software\Wow6432Node\ODBC
最后点击导入就可以了.

上面两个注册表列下来,诸位可以复制到记事本分别存为.reg文件,然后导入自己的机器的注册表就可以了。

reg文件1:
Windows Registry Editor Version 5.00[HKEY_CURRENT_USER\Software\Wow6432Node\ODBC][HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI][HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\dBASE Files]"Driver"="C:\\Windows\\system32\\odbcjt32.dll""DriverId"=dword:00000215"SafeTransactions"=dword:00000000"UID"=""[HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\dBASE Files\Engines][HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\dBASE Files\Engines\Xbase]"ImplicitCommitSync"="""Threads"=dword:00000003"UserCommitSync"="Yes"[HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\Excel Files]"Driver"="C:\\Windows\\system32\\odbcjt32.dll""DriverId"=dword:00000316"SafeTransactions"=dword:00000000"UID"=""[HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\Excel Files\Engines][HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\Excel Files\Engines\Excel]"ImplicitCommitSync"="""Threads"=dword:00000003"UserCommitSync"="Yes""FirstRowHasNames"=hex:01[HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\MS Access Database]"Driver"="C:\\Windows\\system32\\odbcjt32.dll""DriverId"=dword:00000019"SafeTransactions"=dword:00000000"UID"=""[HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\MS Access Database\Engines][HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\MS Access Database\Engines\Jet]"ImplicitCommitSync"="""Threads"=dword:00000003"UserCommitSync"="Yes"[HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\ODBC Data Sources]"Visio Database Samples"="Microsoft Access Driver (*.MDB)""MS Access Database"="Microsoft Access Driver (*.mdb)""Excel Files"="Microsoft Excel Driver (*.xls)""dBASE Files"="Microsoft dBase Driver (*.dbf)"[HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\Visio Database Samples]"SafeTransactions"=dword:00000000"DefaultDir"="\"\"""DBQ"="C:\\PROGRA~1\\MIF5BA~1\\Visio11\\2052\\DBSAMPLE.MDB""DriverId"=dword:00000019"Driver"="C:\\Windows\\system32\\\\odbcjt32.dll""UID"="""ReadOnly"=hex:00[HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\Visio Database Samples\Engines][HKEY_CURRENT_USER\Software\Wow6432Node\ODBC\ODBC.INI\Visio Database Samples\Engines\Jet]"Threads"=dword:00000003"UserCommitSync"="Yes""ImplicitCommitSync"=""reg文件2:
Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC][HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI][HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI][HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Conversor de pagina de codigo MS]"Translator"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,\ 00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4d,00,53,00,43,00,50,00,\ 58,00,4c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4d,00,53,00,43,00,50,00,58,00,\ 4c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"UsageCount"=dword:00000001[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Driver da Microsoft para arquivos texto (*.txt; *.csv)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,74,00,65,00,78,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.,*.asc,*.csv,*.tab,*.txt,*.csv""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Driver do Microsoft Access (*.mdb)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="2""FileExtns"="*.mdb""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Driver do Microsoft dBase (*.dbf)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,64,00,62,00,73,00,\ 65,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.dbf,*.ndx,*.mdx""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Driver do Microsoft Excel(*.xls)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,65,00,78,00,6c,00,\ 33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.xls""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Driver do Microsoft Paradox (*.db )]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,70,00,64,00,78,00,\ 33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.db""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Driver para o Microsoft Visual FoxPro]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,76,00,66,00,70,00,6f,00,64,00,\ 62,00,63,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,76,00,66,00,70,00,6f,00,64,00,\ 62,00,63,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="0""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.dbf,*.cdx,*.idx,*.fpt""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft Access Driver (*.mdb)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="2""FileExtns"="*.mdb""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft Access-Treiber (*.mdb)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="2""FileExtns"="*.mdb""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft dBase Driver (*.dbf)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,64,00,62,00,73,00,\ 65,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.dbf,*.ndx,*.mdx""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft dBase VFP Driver (*.dbf)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,76,00,66,00,70,00,6f,00,64,00,\ 62,00,63,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,76,00,66,00,70,00,6f,00,64,00,\ 62,00,63,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="0""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.dbf,*.cdx,*.idx,*.fpt""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft dBase-Treiber (*.dbf)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,64,00,62,00,73,00,\ 65,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.dbf,*.ndx,*.mdx""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft Excel Driver (*.xls)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,65,00,78,00,6c,00,\ 33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.xls""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft Excel-Treiber (*.xls)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,65,00,78,00,6c,00,\ 33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.xls""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft FoxPro VFP Driver (*.dbf)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,76,00,66,00,70,00,6f,00,64,00,\ 62,00,63,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,76,00,66,00,70,00,6f,00,64,00,\ 62,00,63,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="0""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.dbf,*.cdx,*.idx,*.fpt""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft ODBC forOracle]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,73,00,6f,00,72,00,63,00,\ 6c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6d,00,73,00,6f,00,72,00,63,00,\ 6c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"SQLLevel"="1""FileUsage"="0""DriverODBCVer"="02.50""ConnectFunctions"="YYY""APILevel"="1""CPTimeout"="120"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft Paradox Driver (*.db )]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,70,00,64,00,78,00,\ 33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.db""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft Paradox-Treiber (*.db )]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,70,00,64,00,78,00,\ 33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.db""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft Text Driver (*.txt; *.csv)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,74,00,65,00,78,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.,*.asc,*.csv,*.tab,*.txt,*.csv""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft Text-Treiber (*.txt; *.csv)]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,62,00,63,00,6a,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,6f,00,64,00,74,00,65,00,78,00,\ 74,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="1""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.,*.asc,*.csv,*.tab,*.txt,*.csv""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft Visual FoxPro Driver]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,76,00,66,00,70,00,6f,00,64,00,\ 62,00,63,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,76,00,66,00,70,00,6f,00,64,00,\ 62,00,63,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="0""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.dbf,*.cdx,*.idx,*.fpt""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\Microsoft Visual FoxPro-Treiber]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,76,00,66,00,70,00,6f,00,64,00,\ 62,00,63,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,76,00,66,00,70,00,6f,00,64,00,\ 62,00,63,00,2e,00,64,00,6c,00,6c,00,00,00"APILevel"="0""ConnectFunctions"="YYN""DriverODBCVer"="02.50""FileUsage"="1""FileExtns"="*.dbf,*.cdx,*.idx,*.fpt""SQLLevel"="0"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\MS Code Page Translator]"Translator"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,\ 00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4d,00,53,00,43,00,50,00,\ 58,00,4c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4d,00,53,00,43,00,50,00,58,00,\ 4c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"UsageCount"=dword:00000001[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\MS Code Page-Ubersetzer]"Translator"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,\ 00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4d,00,53,00,43,00,50,00,\ 58,00,4c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,4d,00,53,00,43,00,50,00,58,00,\ 4c,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"UsageCount"=dword:00000001[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Core]"UsageCount"=dword:00000001[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers]"SQL Server"="Installed""Microsoft ODBC for Oracle"="Installed""Microsoft Access Driver (*.mdb)"="Installed""Microsoft Access-Treiber (*.mdb)"="Installed""Driver do Microsoft Access (*.mdb)"="Installed""Microsoft dBase Driver (*.dbf)"="Installed""Microsoft dBase-Treiber (*.dbf)"="Installed""Driver do Microsoft dBase (*.dbf)"="Installed""Microsoft Excel Driver (*.xls)"="Installed""Microsoft Excel-Treiber (*.xls)"="Installed""Driver do Microsoft Excel(*.xls)"="Installed""Microsoft Paradox Driver (*.db )"="Installed""Microsoft Paradox-Treiber (*.db )"="Installed""Driver do Microsoft Paradox (*.db )"="Installed""Microsoft Text Driver (*.txt; *.csv)"="Installed""Microsoft Text-Treiber (*.txt; *.csv)"="Installed""Driver da Microsoft para arquivos texto (*.txt; *.csv)"="Installed""Microsoft Visual FoxPro Driver"="Installed""Microsoft FoxPro VFP Driver (*.dbf)"="Installed""Microsoft dBase VFP Driver (*.dbf)"="Installed""Microsoft Visual FoxPro-Treiber"="Installed""Driver para o Microsoft Visual FoxPro"="Installed"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Translators]"MS Code Page Translator"="Installed""MS Code Page-Ubersetzer"="Installed""Conversor de pagina de codigo MS"="Installed"[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\SQL Server]"UsageCount"=dword:00000001"Driver"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,53,00,51,00,4c,00,53,00,52,00,\ 56,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"Setup"=hex(2):25,00,57,00,49,00,4e,00,44,00,49,00,52,00,25,00,5c,00,73,00,79,\ 00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,73,00,71,00,6c,00,73,00,72,00,\ 76,00,33,00,32,00,2e,00,64,00,6c,00,6c,00,00,00"SQLLevel"="1""FileUsage"="0""DriverODBCVer"="03.50""ConnectFunctions"="YYY""APILevel"="2""CPTimeout"="60"

扩展:office2003错误1919 / 错误1919 配置odbc / odbc数据源配置

扩展:office2003错误1919 / 错误1919 配置odbc / odbc数据源配置

三 : JNDI数据源配置注意事项

如果是在原有工程上修改
1,applicationContext.xml中修改其中的value值
<bean id="dataSource">
<property name="jndiName">
<value>java:comp/env/jndivalue</value>
</property>
</bean>
2,web.xml中修改res-ref-name
<resource-ref>
<res-ref-name>jndivalue</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
3,tomcat中,conf/context.xml中修改或添加
<ResourceLink name="jndivalue" global="jndivalue" type="javax.sql.DataSource"/>

4,tomcat中,conf/server.xml中 <GlobalNamingResources> </GlobalNamingResources>中添加
<Resource name="jndivalue" auth="Container"
type="com.jolbox.bonecp.BoneCPDataSource"
factory="org.apache.naming.factory.BeanFactory"
driverClass="oracle.jdbc.driver.OracleDriver"
username="" password=""
jdbcUrl=""
idleMaxAge="240"
idleConnectionTestPeriod="60"
partitionCount="3"
acquireIncrement="10"
minConnectionsPerPartition="10"
maxConnectionsPerPartition="20"
releaseHelperThreads="3"/>

这四部分的jndivalue最好是统一的,tomcat和工程的纽带是第三部分,如果想不一样,修改第三部分

如果是新建工程,tomcat也是新的,用这种方式的话,需要往tomcat中导入一些jar包

扩展:jndi数据源配置 / tomcat配置jndi数据源 / spring配置jndi数据源

四 : Spring+MyBatis多数据源配置实现

最近用到了MyBatis配置多数据源,原以为简单配置下就行了,实际操作后发现还是要费些事的,这里记录下,以作备忘

不多废话,直接上代码,后面会有简单的实现介绍

jdbc和log4j的配置

targetscan Spring+MyBatis多数据源配置实现targetscan Spring+MyBatis多数据源配置实现

#定义输出格式 ConversionPattern=%d %-5p [%t] %c - %m%n log4j.rootLogger=DEBUG,Console log4j.logger.com.cnblogs.lzrabbit=DEBUG log4j.logger.org.springframework=ERROR log4j.logger.org.mybatis=ERROR log4j.logger.org.apache.ibatis=ERROR log4j.logger.org.quartz=ERROR log4j.logger.org.apache.axis2=ERROR log4j.logger.org.apache.axiom=ERROR log4j.logger.org.apache=ERROR log4j.logger.httpclient=ERROR #log4j.additivity.org.springframework=false #Console log4j.appender.Console=org.apache.log4j.ConsoleAppender log4j.appender.Console.Threshold=DEBUG log4j.appender.Console.Target=System.out log4j.appender.Console.layout=org.apache.log4j.PatternLayout log4j.appender.Console.layout.ConversionPattern=${ConversionPattern} #log4j.appender.Console.encoding=UTF-8 #org.apache.log4j.DailyRollingFileAppender log4j.appender.DailyFile=org.apache.log4j.DailyRollingFileAppender log4j.appender.DailyFile.DatePattern='.'yyyy-MM-dd'.log' log4j.appender.DailyFile.File=${myApp.root}/logs/daily.log log4j.appender.DailyFile.Append=true log4j.appender.DailyFile.Threshold=DEBUG log4j.appender.DailyFile.layout=org.apache.log4j.PatternLayout log4j.appender.DailyFile.layout.ConversionPattern=${ConversionPattern} log4j.appender.DailyFile.encoding=UTF-8 # %c 输出日志信息所属的类的全名 # %d 输出日志时间点的日期或时间,默认格式为ISO8601,也可以在其后指定格式,比如:%d{yyy-MM-dd HH:mm:ss},输出类似:2002-10-18- 22:10:28 # %f 输出日志信息所属的类的类名 # %l 输出日志事件的发生位置,即输出日志信息的语句处于它所在的类的第几行 # %m 输出代码中指定的信息,如log(message)中的message # %n 输出一个回车换行符,Windows平台为“rn”,Unix平台为“n” # %p 输出优先级,即DEBUG,INFO,WARN,ERROR,FATAL。(www.61k.com)如果是调用debug()输出的,则为DEBUG,依此类推 # %r 输出自应用启动到输出该日志信息所耗费的毫秒数 # %t 输出产生该日志事件的线程名

log4j.properties

targetscan Spring+MyBatis多数据源配置实现targetscan Spring+MyBatis多数据源配置实现

#============================================================================ # MySQL #============================================================================ jdbc.mysql.driver=com.mysql.jdbc.Driver jdbc.mysql.url=jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true jdbc.mysql.username=root jdbc.mysql.password=root #============================================================================ # MS SQL Server #============================================================================ #jdbc.sqlserver.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver #jdbc.sqlserver.url=jdbc:sqlserver://127.0.0.1:1433;database=test; #jdbc.sqlserver.username=sa #jdbc.sqlserver.password=sa #============================================================================ # MS SQL Server (JTDS) #============================================================================ jdbc.sqlserver.driver=net.sourceforge.jtds.jdbc.Driver jdbc.sqlserver.url=jdbc:jtds:sqlserver://127.0.0.1:1433/test jdbc.sqlserver.username=sa jdbc.sqlserver.password=sa #============================================================================ # 通用配置 #============================================================================ jdbc.initialSize=5 jdbc.minIdle=5 jdbc.maxIdle=20 jdbc.maxActive=100 jdbc.maxWait=100000 jdbc.defaultAutoCommit=false jdbc.removeAbandoned=true jdbc.removeAbandonedTimeout=600 jdbc.testWhileIdle=true jdbc.timeBetweenEvictionRunsMillis=60000 jdbc.numTestsPerEvictionRun=20 jdbc.minEvictableIdleTimeMillis=300000

jdbc.properties

单数据源时的Spring配置文件

targetscan Spring+MyBatis多数据源配置实现targetscan Spring+MyBatis多数据源配置实现

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:context="http://www.springframework.org/schema/context"  xmlns:aop="http://www.springframework.org/schema/aop"  xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd  http://www.springframework.org/schema/aop  http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">  <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  <property name="location" value="classpath:jdbc.properties"/>  </bean>  <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">  <property name="driverClassName" value="${jdbc.mysql.driver}"/>  <property name="url" value="${jdbc.mysql.url}"/>  <property name="username" value="${jdbc.mysql.username}"/>  <property name="password" value="${jdbc.mysql.password}"/>  <property name="initialSize" value="${jdbc.initialSize}"/>  <property name="minIdle" value="${jdbc.minIdle}"/>  <property name="maxIdle" value="${jdbc.maxIdle}"/>  <property name="maxActive" value="${jdbc.maxActive}"/>  <property name="maxWait" value="${jdbc.maxWait}"/>  <property name="defaultAutoCommit" value="${jdbc.defaultAutoCommit}"/>  <property name="removeAbandoned" value="${jdbc.removeAbandoned}"/>  <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}"/>  <property name="testWhileIdle" value="${jdbc.testWhileIdle}"/>  <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}"/>  <property name="numTestsPerEvictionRun" value="${jdbc.numTestsPerEvictionRun}"/>  <property name="minEvictableIdleTimeMillis" value="${jdbc.minEvictableIdleTimeMillis}"/>  </bean>  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  <property name="dataSource" ref="dataSource"/>  </bean>  <!-- mybatis.spring自动映射 -->  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  <property name="basePackage" value="com.cnblogs.lzrabbit"/>  </bean>  <!-- 自动扫描,多个包以 逗号分隔 -->  <context:component-scan base-package="com.cnblogs.lzrabbit"/>  <aop:aspectj-autoproxy/> </beans>

扩展:spring mybatis数据源 / mybatis多数据源配置 / mybatis数据源配置

applicationContext.xml

多数据源时Spring配置文件

targetscan Spring+MyBatis多数据源配置实现targetscan Spring+MyBatis多数据源配置实现

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:context="http://www.springframework.org/schema/context"  xmlns:aop="http://www.springframework.org/schema/aop"  xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd  http://www.springframework.org/schema/aop  http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">  <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  <property name="location" value="classpath:jdbc.properties"/>  </bean>  <bean id="sqlServerDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">  <property name="driverClassName" value="${jdbc.sqlserver.driver}"/>  <property name="url" value="${jdbc.sqlserver.url}"/>  <property name="username" value="${jdbc.sqlserver.username}"/>  <property name="password" value="${jdbc.sqlserver.password}"/>  <property name="initialSize" value="${jdbc.initialSize}"/>  <property name="minIdle" value="${jdbc.minIdle}"/>  <property name="maxIdle" value="${jdbc.maxIdle}"/>  <property name="maxActive" value="${jdbc.maxActive}"/>  <property name="maxWait" value="${jdbc.maxWait}"/>  <property name="defaultAutoCommit" value="${jdbc.defaultAutoCommit}"/>  <property name="removeAbandoned" value="${jdbc.removeAbandoned}"/>  <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}"/>  <property name="testWhileIdle" value="${jdbc.testWhileIdle}"/>  <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}"/>  <property name="numTestsPerEvictionRun" value="${jdbc.numTestsPerEvictionRun}"/>  <property name="minEvictableIdleTimeMillis" value="${jdbc.minEvictableIdleTimeMillis}"/>  </bean>  <bean id="mySqlDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">  <property name="driverClassName" value="${jdbc.mysql.driver}"/>  <property name="url" value="${jdbc.mysql.url}"/>  <property name="username" value="${jdbc.mysql.username}"/>  <property name="password" value="${jdbc.mysql.password}"/>  <property name="initialSize" value="${jdbc.initialSize}"/>  <property name="minIdle" value="${jdbc.minIdle}"/>  <property name="maxIdle" value="${jdbc.maxIdle}"/>  <property name="maxActive" value="${jdbc.maxActive}"/>  <property name="maxWait" value="${jdbc.maxWait}"/>  <property name="defaultAutoCommit" value="${jdbc.defaultAutoCommit}"/>  <property name="removeAbandoned" value="${jdbc.removeAbandoned}"/>  <property name="removeAbandonedTimeout" value="${jdbc.removeAbandonedTimeout}"/>  <property name="testWhileIdle" value="${jdbc.testWhileIdle}"/>  <property name="timeBetweenEvictionRunsMillis" value="${jdbc.timeBetweenEvictionRunsMillis}"/>  <property name="numTestsPerEvictionRun" value="${jdbc.numTestsPerEvictionRun}"/>  <property name="minEvictableIdleTimeMillis" value="${jdbc.minEvictableIdleTimeMillis}"/>  </bean>  <bean id="multipleDataSource" class="com.cnblogs.lzrabbit.MultipleDataSource">  <property name="defaultTargetDataSource" ref="mySqlDataSource"/>  <property name="targetDataSources">  <map>  <entry key="mySqlDataSource" value-ref="mySqlDataSource"/>  <entry key="sqlServerDataSource" value-ref="sqlServerDataSource"/>  </map>  </property>  </bean>  <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">  <property name="dataSource" ref="multipleDataSource"/>  </bean>  <!-- mybatis.spring自动映射 -->  <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">  <property name="basePackage" value="com.cnblogs.lzrabbit"/>  </bean>  <!-- 自动扫描,多个包以 逗号分隔 -->  <context:component-scan base-package="com.cnblogs.lzrabbit"/>  <aop:aspectj-autoproxy/> </beans>

扩展:spring mybatis数据源 / mybatis多数据源配置 / mybatis数据源配置

applicationContext.xml

MultipleDataSource实现

package com.cnblogs.lzrabbit; import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; /**  * Created by rabbit on 14-5-25.  */ public class MultipleDataSource extends AbstractRoutingDataSource {  private static final ThreadLocal<String> dataSourceKey = new InheritableThreadLocal<String>();  public static void setDataSourceKey(String dataSource) {  dataSourceKey.set(dataSource);  }  @Override  protected Object determineCurrentLookupKey() {  return dataSourceKey.get();  } }

MyBatis接口Mapper定义,直接使用注解方式实现

public interface MySqlMapper {  @Select("select * from MyTable")  List<Map<String,Object>> getList(); } public interface SqlServerMapper {  @Select("select * from MyTable")  List<Map<String,Object>> getList(); }

手动数据源切换调用

package com.cnblogs.lzrabbit; import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; /**  * Created by rabbit on 14-5-25.  */ public class Main {  public static void main(String[] args) {  //初始化ApplicationContext  ApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");  MySqlMapper mySqlMapper = applicationContext.getBean(MySqlMapper.class);  SqlServerMapper sqlServerMapper = applicationContext.getBean(SqlServerMapper.class);  //设置数据源为MySql,使用了AOP测试时请将下面这行注释  MultipleDataSource.setDataSourceKey("mySqlDataSource");  mySqlMapper.getList();  //设置数据源为SqlServer,使用AOP测试时请将下面这行注释  MultipleDataSource.setDataSourceKey("sqlServerDataSource");  sqlServerMapper.getList();  } }

使用SpringAOP方式实现自动切换

package com.cnblogs.lzrabbit; import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.annotation.Around; import org.aspectj.lang.annotation.Aspect; import org.springframework.stereotype.Component; @Component @Aspect public class MultipleDataSourceAspectAdvice {  @Around("execution(* com.cnblogs.lzrabbit.*.*(..))")  public Object doAround(ProceedingJoinPoint jp) throws Throwable {  if (jp.getTarget() instanceof MySqlMapper) {  MultipleDataSource.setDataSourceKey("mySqlDataSource");  } else if (jp.getTarget() instanceof SqlServerMapper) {  MultipleDataSource.setDataSourceKey("sqlServerDataSource");  }  return jp.proceed();  } }

调用日志

2014-05-25 20:02:04,319 DEBUG [main] com.cnblogs.lzrabbit.MySqlMapper.getList - ooo Using Connection [jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true, UserName=root@192.168.1.32, MySQL Connector Java] 2014-05-25 20:02:04,333 DEBUG [main] com.cnblogs.lzrabbit.MySqlMapper.getList - ==> Preparing: select * from MyTable 2014-05-25 20:02:04,371 DEBUG [main] com.cnblogs.lzrabbit.MySqlMapper.getList - ==> Parameters: 2014-05-25 20:02:04,396 DEBUG [main] com.cnblogs.lzrabbit.MySqlMapper.getList - <== Total: 8 2014-05-25 20:02:04,620 DEBUG [main] com.cnblogs.lzrabbit.SqlServerMapper.getList - ooo Using Connection [jdbc:jtds:sqlserver://127.0.0.1:1433/test, UserName=sa, jTDS Type 4 JDBC Driver for MS SQL Server and Sybase] 2014-05-25 20:02:04,620 DEBUG [main] com.cnblogs.lzrabbit.SqlServerMapper.getList - ==> Preparing: select * from TmallCityMap 2014-05-25 20:02:04,621 DEBUG [main] com.cnblogs.lzrabbit.SqlServerMapper.getList - ==> Parameters: 2014-05-25 20:02:04,681 DEBUG [main] com.cnblogs.lzrabbit.SqlServerMapper.getList - <== Total: 397

这里就上面的实现做个简单解释,在我们配置单数据源时可以看到数据源类型使用了org.apache.commons.dbcp.BasicDataSource,而这个代码实现了javax.sql.DataSource接口

配置sqlSessionFactory时org.mybatis.spring.SqlSessionFactoryBean注入参数dataSource类型就是javax.sql.DataSource

实现多数据源的方法就是我们自定义了一个MultipleDataSource,这个类继承自AbstractRoutingDataSource,而AbstractRoutingDataSource继承自AbstractDataSource ,AbstractDataSource 实现了javax.sql.DataSource接口,所以我们的MultipleDataSource也实现了javax.sql.DataSource接口,可以赋值给sqlSessionFactory的dataSource属性

public abstract class AbstractRoutingDataSource extends AbstractDataSource implements InitializingBean { } public abstract class AbstractDataSource implements DataSource { }

 再来说下MultipleDataSource的实现原理,MultipleDataSource实现AbstractRoutingDataSource抽象类,然后实现了determineCurrentLookupKey方法,这个方法用于选择具体使用targetDataSources中的哪一个数据源

<bean id="multipleDataSource" class="com.cnblogs.lzrabbit.MultipleDataSource">  <property name="defaultTargetDataSource" ref="mySqlDataSource"/>  <property name="targetDataSources">  <map>  <entry key="mySqlDataSource" value-ref="mySqlDataSource"/>  <entry key="sqlServerDataSource" value-ref="sqlServerDataSource"/>  </map>  </property>  </bean>

扩展:spring mybatis数据源 / mybatis多数据源配置 / mybatis数据源配置

可以看到Spring配置中multipleDataSource设置了两个属性defaultTargetDataSource和targetDataSources,这两个属性定义在AbstractRoutingDataSource,当MyBatis执行查询时会先选择数据源,选择顺序时现根据determineCurrentLookupKey方法返回的值到targetDataSources中去找,若能找到怎返回对应的数据源,若找不到返回默认的数据源defaultTargetDataSource,具体参考AbstractRoutingDataSource的源码

public abstract class AbstractRoutingDataSource extends AbstractDataSource implements InitializingBean {  private Map<Object, Object> targetDataSources;  private Object defaultTargetDataSource;  /**  * Retrieve the current target DataSource. Determines the  * {@link #determineCurrentLookupKey() current lookup key}, performs  * a lookup in the {@link #setTargetDataSources targetDataSources} map,  * falls back to the specified  * {@link #setDefaultTargetDataSource default target DataSource} if necessary.  * @see #determineCurrentLookupKey()  */  protected DataSource determineTargetDataSource() {  Assert.notNull(this.resolvedDataSources, "DataSource router not initialized");  Object lookupKey = determineCurrentLookupKey();  DataSource dataSource = this.resolvedDataSources.get(lookupKey);  if (dataSource == null && (this.lenientFallback || lookupKey == null)) {  dataSource = this.resolvedDefaultDataSource;  }  if (dataSource == null) {  throw new IllegalStateException("Cannot determine target DataSource for lookup key [" + lookupKey + "]");  }  return dataSource;  }  /**  * Determine the current lookup key. This will typically be  * implemented to check a thread-bound transaction context.  * <p>Allows for arbitrary keys. The returned key needs  * to match the stored lookup key type, as resolved by the  * {@link #resolveSpecifiedLookupKey} method.  */  protected abstract Object determineCurrentLookupKey();

............. }

 在动态切换数据源方法时选择了AOP方式实现,这里实现的简单粗暴,具体应用时根据实际需要灵活变通吧

题外话,这里提下SqlServer驱动选择的问题,目前SqlServer的驱动主要有微软的官方驱动和JTDS驱动两种,关于这两个驱动我做过测试,批量更新,在小数据量(100以下)时,JTDS相对微软驱动性能稍微高一点点,在数据量增大时几万到上百万时,微软驱动有着明显优势,所以若对性能比较敏感,建议使用微软驱动,否则随意

微软驱动在Maven库找不到,这点比较郁闷,若使用maven的话还得先安装到本地,这点很不爽

JTDS使用比较方便Maven直接引用即可

相关jar maven引用

targetscan Spring+MyBatis多数据源配置实现targetscan Spring+MyBatis多数据源配置实现

<properties>  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>  <org.springframework.version>3.2.7.RELEASE</org.springframework.version>  </properties>  <dependencies>  <dependency>  <groupId>org.aspectj</groupId>  <artifactId>aspectjweaver</artifactId>  <version>1.7.2</version>  </dependency>  <dependency>  <groupId>commons-dbcp</groupId>  <artifactId>commons-dbcp</artifactId>  <version>1.4</version>  </dependency>  <dependency>  <groupId>commons-logging</groupId>  <artifactId>commons-logging</artifactId>  <version>1.1.3</version>  </dependency>  <dependency>  <groupId>log4j</groupId>  <artifactId>log4j</artifactId>  <version>1.2.17</version>  </dependency>  <dependency>  <groupId>org.springframework</groupId>  <artifactId>spring-core</artifactId>  <version>${org.springframework.version}</version>  </dependency>  <dependency>  <groupId>org.springframework</groupId>  <artifactId>spring-beans</artifactId>  <version>${org.springframework.version}</version>  </dependency>  <dependency>  <groupId>org.springframework</groupId>  <artifactId>spring-aop</artifactId>  <version>${org.springframework.version}</version>  </dependency>  <dependency>  <groupId>org.springframework</groupId>  <artifactId>spring-context</artifactId>  <version>${org.springframework.version}</version>  </dependency>  <dependency>  <groupId>org.springframework</groupId>  <artifactId>spring-jdbc</artifactId>  <version>${org.springframework.version}</version>  </dependency>  <dependency>  <groupId>org.springframework</groupId>  <artifactId>spring-context-support</artifactId>  <version>${org.springframework.version}</version>  </dependency>  <dependency>  <groupId>org.springframework</groupId>  <artifactId>spring-web</artifactId>  <version>${org.springframework.version}</version>  </dependency>  <dependency>  <groupId>org.springframework</groupId>  <artifactId>spring-webmvc</artifactId>  <version>${org.springframework.version}</version>  </dependency>  <dependency>  <groupId>org.springframework</groupId>  <artifactId>spring-tx</artifactId>  <version>${org.springframework.version}</version>  </dependency>  <dependency>  <groupId>org.mybatis</groupId>  <artifactId>mybatis</artifactId>  <version>3.2.4</version>  </dependency>  <dependency>  <groupId>org.mybatis</groupId>  <artifactId>mybatis-spring</artifactId>  <version>1.2.2</version>  </dependency>  <dependency>  <groupId>org.slf4j</groupId>  <artifactId>slf4j-log4j12</artifactId>  <version>1.7.6</version>  </dependency>  <dependency>  <groupId>net.sourceforge.jtds</groupId>  <artifactId>jtds</artifactId>  <version>1.2.8</version>  </dependency>  <dependency>  <groupId>mysql</groupId>  <artifactId>mysql-connector-java</artifactId>  <version>5.1.29</version>  </dependency>  </dependencies>

扩展:spring mybatis数据源 / mybatis多数据源配置 / mybatis数据源配置

View Code

扩展:spring mybatis数据源 / mybatis多数据源配置 / mybatis数据源配置

五 : 配置SQL Server ODBC数据源

■ 配置SQL Server ODBC数据源

================================

在XP操作系统下配置SQL Server ODBC数据源步骤,辅助调试。

第一步

在控制面板下选择 管理工具->ODBC数据源,双击图标

  出现如下界面



第二步

在系统DSN 选项卡片上,单击“添加(D)”按钮,出现 创建新数据源 对话框,选择SQL Server



第三步

单击第二步的“完成”按钮,出现创建到SQL Server的新数据源。如下图所示。

输入数据源名称、数据源描述和SQL Server 所在的服务器名称或者IP地址。服务器名称可以是SQL Server所在的机器名称,也可以是IP地址。单击下一步按钮。



第四步

选择登录SQL Server时的身份验证方式。并输入登录SQL Server时所用到的用户名和密码。如下图所示。



这里的用户名和密码是在SQL Server中建立的。在SQL Server数据库中选择 安全性->登录,如下图所示。

关键点,点击“客户端配置(T)...”按钮,可以反复在“Named Pipes(P)”和“TCP/IP(T)”调试。

故障现象:

A、软件并不用ODBC作为数据源访问数据库,安装时有时会碰到网络版连接不上数据库的情况,Telnet指令测试成功!这时用ODBC配置一下,故障解除!

B、“TCP/IP(T)”数据源配置失败的情况下,可以再尝试“Named Pipes(P)”,配置数据源,基本可以故障解除!

故障原因:操作系统,在日常使用中,发生较大改动所致。





第五步

默认数据库是master,因测试联接,所以不用更改数据库。然后单击下一步按钮。



第六步

按默认设置,单击完成按钮。



第七步

这里给出了数据库连接的摘要信息,如果想测试一下是否能够连接到数据库,可以单击“测试数据源(T)...”按钮,会出现测试结果,如下图所示。



本文标题:odbc数据源配置-Steam大数据公布出PC玩家应有的基本配置
本文地址: http://www.61k.com/1070006.html

61阅读| 精彩专题| 最新文章| 热门文章| 苏ICP备13036349号-1