JAVA数据库连接池实现

转载自   JAVA数据库连接池实现

连接池的管理用了了享元模式,这里对连接池进行简单设计。

一、设计思路

     1.连接池配置属性DBbean:里面存放可以配置的一些属性

     2.连接池接口IConnectionPool:里面定义一些基本的获取连接的一些方法

     3.接口实现ConnectionPool:对上面操作进行实现,并加入一些其他方法

     4.连接池管理ConnectionPoolManager:管理所有的不同的连接池,所有的连接都能通过这里进行获得连接

     5.另外还有几个测试类,和连接信息模拟的类,这里就不进行xml 和配置文件信息的读取了

  1. package pool;  
  2. /** 
  3.  * 这是外部可以配置的连接池属性 
  4.  * 可以允许外部配置,拥有默认值 
  5.  * @author Ran 
  6.  * 
  7.  */  
  8. public class DBbean {  
  9.     // 连接池属性  
  10.     private String driverName;  
  11.     private String url;  
  12.     private String userName;  
  13.     private String password;  
  14.     // 连接池名字  
  15.     private String poolName;  
  16.     private int minConnections = 1// 空闲池,最小连接数  
  17.     private int maxConnections = 10// 空闲池,最大连接数  
  18.       
  19.     private int initConnections = 5;// 初始化连接数  
  20.       
  21.     private long connTimeOut = 1000;// 重复获得连接的频率  
  22.       
  23.     private int maxActiveConnections = 100;// 最大允许的连接数,和数据库对应  
  24.       
  25.     private long connectionTimeOut = 1000*60*20;// 连接超时时间,默认20分钟  
  26.       
  27.     private boolean isCurrentConnection = true// 是否获得当前连接,默认true  
  28.       
  29.     private boolean isCheakPool = true// 是否定时检查连接池  
  30.     private long lazyCheck = 1000*60*60;// 延迟多少时间后开始 检查  
  31.     private long periodCheck = 1000*60*60;// 检查频率  
  32.       
  33.       
  34.       
  35.     public DBbean(String driverName, String url, String userName,  
  36.             String password, String poolName) {  
  37.         super();  
  38.         this.driverName = driverName;  
  39.         this.url = url;  
  40.         this.userName = userName;  
  41.         this.password = password;  
  42.         this.poolName = poolName;  
  43.     }  
  44.     public DBbean() {  
  45.     }  
  46.     public String getDriverName() {  
  47.         if(driverName == null){  
  48.             driverName = this.getDriverName()+"_"+this.getUrl();  
  49.         }  
  50.         return driverName;  
  51.     }  
  52.     public void setDriverName(String driverName) {  
  53.         this.driverName = driverName;  
  54.     }  
  55.     public String getUrl() {  
  56.         return url;  
  57.     }  
  58.     public void setUrl(String url) {  
  59.         this.url = url;  
  60.     }  
  61.     public String getUserName() {  
  62.         return userName;  
  63.     }  
  64.     public void setUserName(String userName) {  
  65.         this.userName = userName;  
  66.     }  
  67.     public String getPassword() {  
  68.         return password;  
  69.     }  
  70.     public void setPassword(String password) {  
  71.         this.password = password;  
  72.     }  
  73.     public String getPoolName() {  
  74.         return poolName;  
  75.     }  
  76.     public void setPoolName(String poolName) {  
  77.         this.poolName = poolName;  
  78.     }  
  79.     public int getMinConnections() {  
  80.         return minConnections;  
  81.     }  
  82.     public void setMinConnections(int minConnections) {  
  83.         this.minConnections = minConnections;  
  84.     }  
  85.     public int getMaxConnections() {  
  86.         return maxConnections;  
  87.     }  
  88.     public void setMaxConnections(int maxConnections) {  
  89.         this.maxConnections = maxConnections;  
  90.     }  
  91.     public int getInitConnections() {  
  92.         return initConnections;  
  93.     }  
  94.     public void setInitConnections(int initConnections) {  
  95.         this.initConnections = initConnections;  
  96.     }  
  97.   
  98.     public int getMaxActiveConnections() {  
  99.         return maxActiveConnections;  
  100.     }  
  101.     public void setMaxActiveConnections(int maxActiveConnections) {  
  102.         this.maxActiveConnections = maxActiveConnections;  
  103.     }  
  104.     public long getConnTimeOut() {  
  105.         return connTimeOut;  
  106.     }  
  107.     public void setConnTimeOut(long connTimeOut) {  
  108.         this.connTimeOut = connTimeOut;  
  109.     }  
  110.     public long getConnectionTimeOut() {  
  111.         return connectionTimeOut;  
  112.     }  
  113.     public void setConnectionTimeOut(long connectionTimeOut) {  
  114.         this.connectionTimeOut = connectionTimeOut;  
  115.     }  
  116.     public boolean isCurrentConnection() {  
  117.         return isCurrentConnection;  
  118.     }  
  119.     public void setCurrentConnection(boolean isCurrentConnection) {  
  120.         this.isCurrentConnection = isCurrentConnection;  
  121.     }  
  122.     public long getLazyCheck() {  
  123.         return lazyCheck;  
  124.     }  
  125.     public void setLazyCheck(long lazyCheck) {  
  126.         this.lazyCheck = lazyCheck;  
  127.     }  
  128.     public long getPeriodCheck() {  
  129.         return periodCheck;  
  130.     }  
  131.     public void setPeriodCheck(long periodCheck) {  
  132.         this.periodCheck = periodCheck;  
  133.     }  
  134.     public boolean isCheakPool() {  
  135.         return isCheakPool;  
  136.     }  
  137.     public void setCheakPool(boolean isCheakPool) {  
  138.         this.isCheakPool = isCheakPool;  
  139.     }  
  140.       
  141.       
  142.       
  143. }  

 

Java代码  收藏代码
  1. package pool;  
  2.   
  3. import java.sql.Connection;  
  4. import java.sql.SQLException;  
  5.   
  6. public interface IConnectionPool {  
  7.     // 获得连接  
  8.     public Connection  getConnection();  
  9.     // 获得当前连接  
  10.     public Connection getCurrentConnecton();  
  11.     // 回收连接  
  12.     public void releaseConn(Connection conn) throws SQLException;  
  13.     // 销毁清空  
  14.     public void destroy();  
  15.     // 连接池是活动状态  
  16.     public boolean isActive();  
  17.     // 定时器,检查连接池  
  18.     public void cheackPool();  
  19. }  


  1. package pool;  
  2.   
  3. import java.sql.Connection;  
  4. import java.sql.DriverManager;  
  5. import java.sql.SQLException;  
  6. import java.util.List;  
  7. import java.util.Timer;  
  8. import java.util.TimerTask;  
  9. import java.util.Vector;  
  10.   
  11. public class ConnectionPool implements IConnectionPool {  
  12.     // 连接池配置属性  
  13.     private DBbean dbBean;  
  14.     private boolean isActive = false// 连接池活动状态  
  15.     private int contActive = 0;// 记录创建的总的连接数  
  16.       
  17.     // 空闲连接  
  18.     private List<Connection> freeConnection = new Vector<Connection>();  
  19.     // 活动连接  
  20.     private List<Connection> activeConnection = new Vector<Connection>();  
  21.     // 将线程和连接绑定,保证事务能统一执行  
  22.     private static ThreadLocal<Connection> threadLocal = new ThreadLocal<Connection>();  
  23.       
  24.     public ConnectionPool(DBbean dbBean) {  
  25.         super();  
  26.         this.dbBean = dbBean;  
  27.         init();  
  28.         cheackPool();  
  29.     }  
  30.   
  31.     // 初始化  
  32.     public void init() {  
  33.         try {  
  34.             Class.forName(dbBean.getDriverName());  
  35.             for (int i = 0; i < dbBean.getInitConnections(); i++) {  
  36.                 Connection conn;  
  37.                 conn = newConnection();  
  38.                 // 初始化最小连接数  
  39.                 if (conn != null) {  
  40.                     freeConnection.add(conn);  
  41.                     contActive++;  
  42.                 }  
  43.             }  
  44.             isActive = true;  
  45.         } catch (ClassNotFoundException e) {  
  46.             e.printStackTrace();  
  47.         } catch (SQLException e) {  
  48.             e.printStackTrace();  
  49.         }  
  50.     }  
  51.       
  52.     // 获得当前连接  
  53.     public Connection getCurrentConnecton(){  
  54.         // 默认线程里面取  
  55.         Connection conn = threadLocal.get();  
  56.         if(!isValid(conn)){  
  57.             conn = getConnection();  
  58.         }  
  59.         return conn;  
  60.     }  
  61.   
  62.     // 获得连接  
  63.     public synchronized Connection getConnection() {  
  64.         Connection conn = null;  
  65.         try {  
  66.             // 判断是否超过最大连接数限制  
  67.             if(contActive < this.dbBean.getMaxActiveConnections()){  
  68.                 if (freeConnection.size() > 0) {  
  69.                     conn = freeConnection.get(0);  
  70.                     if (conn != null) {  
  71.                         threadLocal.set(conn);  
  72.                     }  
  73.                     freeConnection.remove(0);  
  74.                 } else {  
  75.                     conn = newConnection();  
  76.                 }  
  77.                   
  78.             }else{  
  79.                 // 继续获得连接,直到从新获得连接  
  80.                 wait(this.dbBean.getConnTimeOut());  
  81.                 conn = getConnection();  
  82.             }  
  83.             if (isValid(conn)) {  
  84.                 activeConnection.add(conn);  
  85.                 contActive ++;  
  86.             }  
  87.         } catch (SQLException e) {  
  88.             e.printStackTrace();  
  89.         } catch (ClassNotFoundException e) {  
  90.             e.printStackTrace();  
  91.         } catch (InterruptedException e) {  
  92.             e.printStackTrace();  
  93.         }  
  94.         return conn;  
  95.     }  
  96.   
  97.     // 获得新连接  
  98.     private synchronized Connection newConnection()  
  99.             throws ClassNotFoundException, SQLException {  
  100.         Connection conn = null;  
  101.         if (dbBean != null) {  
  102.             Class.forName(dbBean.getDriverName());  
  103.             conn = DriverManager.getConnection(dbBean.getUrl(),  
  104.                     dbBean.getUserName(), dbBean.getPassword());  
  105.         }  
  106.         return conn;  
  107.     }  
  108.   
  109.     // 释放连接  
  110.     public synchronized void releaseConn(Connection conn) throws SQLException {  
  111.         if (isValid(conn)&& !(freeConnection.size() > dbBean.getMaxConnections())) {  
  112.             freeConnection.add(conn);  
  113.             activeConnection.remove(conn);  
  114.             contActive --;  
  115.             threadLocal.remove();  
  116.             // 唤醒所有正待等待的线程,去抢连接  
  117.             notifyAll();  
  118.         }  
  119.     }  
  120.   
  121.     // 判断连接是否可用  
  122.     private boolean isValid(Connection conn) {  
  123.         try {  
  124.             if (conn == null || conn.isClosed()) {  
  125.                 return false;  
  126.             }  
  127.         } catch (SQLException e) {  
  128.             e.printStackTrace();  
  129.         }  
  130.         return true;  
  131.     }  
  132.   
  133.     // 销毁连接池  
  134.     public synchronized void destroy() {  
  135.         for (Connection conn : freeConnection) {  
  136.             try {  
  137.                 if (isValid(conn)) {  
  138.                     conn.close();  
  139.                 }  
  140.             } catch (SQLException e) {  
  141.                 e.printStackTrace();  
  142.             }  
  143.         }  
  144.         for (Connection conn : activeConnection) {  
  145.             try {  
  146.                 if (isValid(conn)) {  
  147.                     conn.close();  
  148.                 }  
  149.             } catch (SQLException e) {  
  150.                 e.printStackTrace();  
  151.             }  
  152.         }  
  153.         isActive = false;  
  154.         contActive = 0;  
  155.     }  
  156.   
  157.     // 连接池状态  
  158.     @Override  
  159.     public boolean isActive() {  
  160.         return isActive;  
  161.     }  
  162.       
  163.     // 定时检查连接池情况  
  164.     @Override  
  165.     public void cheackPool() {  
  166.         if(dbBean.isCheakPool()){  
  167.             new Timer().schedule(new TimerTask() {  
  168.             @Override  
  169.             public void run() {  
  170.             // 1.对线程里面的连接状态  
  171.             // 2.连接池最小 最大连接数  
  172.             // 3.其他状态进行检查,因为这里还需要写几个线程管理的类,暂时就不添加了  
  173.             System.out.println("空线池连接数:"+freeConnection.size());  
  174.             System.out.println("活动连接数::"+activeConnection.size());  
  175.             System.out.println("总的连接数:"+contActive);  
  176.                 }  
  177.             },dbBean.getLazyCheck(),dbBean.getPeriodCheck());  
  178.         }  
  179.     }  
  180. }  


  1. package pool;  
  2.   
  3. import java.sql.Connection;  
  4. import java.sql.SQLException;  
  5. import java.util.Hashtable;  
  6. /** 
  7.  * 连接管理类 
  8.  * @author Ran 
  9.  * 
  10.  */  
  11. public class ConnectionPoolManager {  
  12.       
  13.       
  14.     // 连接池存放  
  15.     public Hashtable<String,IConnectionPool> pools = new Hashtable<String, IConnectionPool>();  
  16.       
  17.     // 初始化  
  18.     private ConnectionPoolManager(){  
  19.         init();  
  20.     }  
  21.     // 单例实现  
  22.     public static ConnectionPoolManager getInstance(){  
  23.         return Singtonle.instance;  
  24.     }  
  25.     private static class Singtonle {  
  26.         private static ConnectionPoolManager instance =  new ConnectionPoolManager();  
  27.     }  
  28.       
  29.       
  30.     // 初始化所有的连接池  
  31.     public void init(){  
  32.         for(int i =0;i<DBInitInfo.beans.size();i++){  
  33.             DBbean bean = DBInitInfo.beans.get(i);  
  34.             ConnectionPool pool = new ConnectionPool(bean);  
  35.             if(pool != null){  
  36.                 pools.put(bean.getPoolName(), pool);  
  37.                 System.out.println("Info:Init connection successed ->" +bean.getPoolName());  
  38.             }  
  39.         }  
  40.     }  
  41.       
  42.     // 获得连接,根据连接池名字 获得连接  
  43.     public Connection  getConnection(String poolName){  
  44.         Connection conn = null;  
  45.         if(pools.size()>0 && pools.containsKey(poolName)){  
  46.             conn = getPool(poolName).getConnection();  
  47.         }else{  
  48.             System.out.println("Error:Can't find this connecion pool ->"+poolName);  
  49.         }  
  50.         return conn;  
  51.     }  
  52.       
  53.     // 关闭,回收连接  
  54.     public void close(String poolName,Connection conn){  
  55.             IConnectionPool pool = getPool(poolName);  
  56.             try {  
  57.                 if(pool != null){  
  58.                     pool.releaseConn(conn);  
  59.                 }  
  60.             } catch (SQLException e) {  
  61.                 System.out.println("连接池已经销毁");  
  62.                 e.printStackTrace();  
  63.             }  
  64.     }  
  65.       
  66.     // 清空连接池  
  67.     public void destroy(String poolName){  
  68.         IConnectionPool pool = getPool(poolName);  
  69.         if(pool != null){  
  70.             pool.destroy();  
  71.         }  
  72.     }  
  73.       
  74.     // 获得连接池  
  75.     public IConnectionPool getPool(String poolName){  
  76.         IConnectionPool pool = null;  
  77.         if(pools.size() > 0){  
  78.              pool = pools.get(poolName);  
  79.         }  
  80.         return pool;  
  81.     }  
  82. }  

 

  1. package pool;  
  2.   
  3. import java.util.ArrayList;  
  4. import java.util.List;  
  5. /** 
  6.  * 初始化,模拟加载所有的配置文件 
  7.  * @author Ran 
  8.  * 
  9.  */  
  10. public class DBInitInfo {  
  11.     public  static List<DBbean>  beans = null;  
  12.     static{  
  13.         beans = new ArrayList<DBbean>();  
  14.         // 这里数据 可以从xml 等配置文件进行获取  
  15.         // 为了测试,这里我直接写死  
  16.         DBbean beanOracle = new DBbean();  
  17.         beanOracle.setDriverName("oracle.jdbc.driver.OracleDriver");  
  18.         beanOracle.setUrl("jdbc:oracle:thin:@7MEXGLUY95W1Y56:1521:orcl");  
  19.         beanOracle.setUserName("mmsoa");  
  20.         beanOracle.setPassword("password1234");  
  21.           
  22.         beanOracle.setMinConnections(5);  
  23.         beanOracle.setMaxConnections(100);  
  24.           
  25.         beanOracle.setPoolName("testPool");  
  26.         beans.add(beanOracle);  
  27.     }  
  28. }  

 

    测试:

  1. package pool;  
  2.   
  3. import java.sql.Connection;  
  4. /** 
  5.  * 模拟线程启动,去获得连接 
  6.  * @author Ran 
  7.  * 
  8.  */  
  9. public class ThreadConnection implements Runnable{  
  10.     private IConnectionPool pool;  
  11.     @Override  
  12.     public void run() {  
  13.         pool = ConnectionPoolManager.getInstance().getPool("testPool");  
  14.     }  
  15.       
  16.     public Connection getConnection(){  
  17.         Connection conn = null;  
  18.         if(pool != null && pool.isActive()){  
  19.             conn = pool.getConnection();  
  20.         }  
  21.         return conn;  
  22.     }  
  23.       
  24.     public Connection getCurrentConnection(){  
  25.         Connection conn = null;  
  26.         if(pool != null && pool.isActive()){  
  27.             conn = pool.getCurrentConnecton();  
  28.         }  
  29.         return conn;  
  30.     }  
  31. }  

 

  1. package pool;  
  2.   
  3.   
  4.   
  5. public class Client {  
  6.     public static void main(String[] args) throws InterruptedException {  
  7.         // 初始化连接池  
  8.         Thread t = init();  
  9.         t.start();  
  10.         t.join();  
  11.           
  12.         ThreadConnection a = new ThreadConnection();  
  13.         ThreadConnection b = new ThreadConnection();  
  14.         ThreadConnection c = new ThreadConnection();  
  15.         Thread t1 = new Thread(a);  
  16.         Thread t2 = new Thread(b);  
  17.         Thread t3 = new Thread(c);  
  18.           
  19.           
  20.         // 设置优先级,先让初始化执行,模拟 线程池 先启动  
  21.         // 这里仅仅表面控制了,因为即使t 线程先启动,也不能保证pool 初始化完成,为了简单模拟,这里先这样写了  
  22.         t1.setPriority(10);  
  23.         t2.setPriority(10);  
  24.         t3.setPriority(10);  
  25.         t1.start();  
  26.         t2.start();  
  27.         t3.start();  
  28.           
  29.         System.out.println("线程A-> "+a.getConnection());  
  30.         System.out.println("线程B-> "+b.getConnection());  
  31.         System.out.println("线程C-> "+c.getConnection());  
  32.     }  
  33.   
  34.     // 初始化  
  35.     public static Thread init() {  
  36.         Thread t = new Thread(new Runnable() {  
  37.             @Override  
  38.             public void run() {  
  39.                 IConnectionPool  pool = initPool();  
  40.                 while(pool == null || !pool.isActive()){  
  41.                     pool = initPool();  
  42.                 }  
  43.             }  
  44.         });  
  45.         return t;  
  46.     }  
  47.       
  48.     public static IConnectionPool initPool(){  
  49.         return ConnectionPoolManager.getInstance().getPool("testPool");  
  50.     }  
  51.   
  52. }  

 

小结 :

          1.连接池诞生原因是,如果每次都从数据库获得连接,时间比较长,因此我们提前做建立一些连接,放在连接池里面,每次都从里面取

          2.上面仅仅写了连接池基本原理,关于多线程下连接池的管理没写,后面对多线程操作熟练了添加吧


本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/328848.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

在.NET开发面向Oracle数据库的应用程序

其实这个不是一个什么新的话题。但是之前在多次项目中&#xff0c;总是遇到大家针对Oracle数据库的访问时&#xff0c;会有各种各样的问题&#xff0c;最基本的就是要在客户端安装各种client&#xff0c;版本不一样的话还有各种问题。 静下心来看看&#xff0c;其实也没有那么难…

服务器ubuntu系统版本选型原则,系统集成 - 选择Ubuntu服务器版操作系统的六大理由_服务器应用_Linux公社-Linux系统门户网站...

二. 系统集成(1)集成现有的系统Ubuntu服务器版本用常用的身份认证方式和服务入口工具简单地集成企业现有的客户/服务器结构。我们都知道系统集成技术的重要性&#xff0c;这也是Ubuntu团队花费大量时间研究如何实现服务器与基础设施简单融合的原因。(2)简单的验证方式验证功能对…

sql serve基础

一、数据库登录名与数据库用户1.登录名登录服务器2.数据库用户访问具体数据库二者要建立映射关系二、数据库文件&#xff1a;1.主数据文件&#xff1a;*.mdf&#xff08;必须&#xff09;2.辅助数据文件&#xff1a;*.ndf(可选)3.日志文件&#xff1a;*.ldf&#xff08;必须&am…

sql基本操作语句

sql: 结构化查询语言T-SQL:sql server数据库中用的查询语言数据库对象操作&#xff1a;一、建库&#xff1a;二、建表&#xff1a;三、数据操作1.添加INSERT [INTO] 表名 (列列表) VALUES(值列表)a. 列列表和值列表一一对应&#xff08;顺序和个数&#xff09;b。可以为null的…

云服务器mqtt协议,云服务器mqtt协议

云服务器mqtt协议 内容精选换一换IPv6的使用&#xff0c;可以有效弥补IPv4网络地址资源有限的问题。如果当前云服务器使用IPv4&#xff0c;那么启用IPv6后&#xff0c;云服务器可在双栈模式下运行&#xff0c;即云服务器可以拥有两个不同版本的IP地址&#xff1a;IPv4地址和IPv…

常用的推荐算法解析

转载自 常用的推荐算法解析1. 前言随着互联网技术和社会化网络的发展&#xff0c;每天有大量包括博客&#xff0c;图片&#xff0c;视频&#xff0c;微博等等的信息发布到网上。传统的搜索技术已经不能满足用户对信息发现的需求&#xff0c;原因有多种&#xff0c;可能是用户…

一步一步封装自己的HtmlHelper组件:BootstrapHelper

前言&#xff1a;之前学习过很多的Bootstrap组件&#xff0c;博主就在脑海里构思&#xff1a;是否可以封装一套自己Bootstrap组件库呢。再加上看到MVC的Razor语法里面直接通过后台方法输出前端控件的方式&#xff0c;于是打算仿照HtmlHelper封装一套BootstrapHelper&#xff0c…

sql server简单查询

一、插入多行数据&#xff1a;1.insert into 。。。 select 从一个表中取出数据插入另一个已存在的表2.select into 从一个表中取出数据插入一个新表中3.insert into ()unionselect 常量列表 二、简单查询1. 查询所有行和列 SELECT * FROM 表名2.查询部分列 SELECT 列列…

推荐系统常用的推荐算法

转载自 推荐系统常用的推荐算法 一、推荐系统概述和常用评价指标1.1 推荐系统的特点 在知乎搜了一下推荐系统&#xff0c;果真结果比较少&#xff0c;显得小众一些&#xff0c;然后大家对推荐系统普遍的观点是&#xff1a; (1)重要性UI>数据>算法&#xff0c;就是推荐系…

拥抱.NET Core,学习.NET Core的基础知识补遗

前言 .NET Core的新特性之一就是跨平台&#xff0c;但由于对之前框架的兼容导致编写一个.NET Core类库变得相当复杂&#xff0c;主要体现为相当多的框架目标和支持平台&#xff0c;今天我们就对.NET Core的跨平台特性进行一次梳理。 在.NET Core之前 其实早在.NET Core之前微软…

sql server模糊查询、分组

一、系统函数1。convert&#xff08;类型[length] &#xff0c;表达式[&#xff0c;样式]&#xff09;2.isnull&#xff08;表达式&#xff0c;默认值&#xff09;字符函数&#xff1a;len() 长度ltrim&#xff08;&#xff09;|rtrim&#xff08;&#xff09;去除左右空格righ…

拥抱.NET Core,如何开发一个跨平台类库

在此前的文章中详细介绍了使用.NET Core的基本知识&#xff0c;如果还没有看&#xff0c;可以先去了解“拥抱.NET Core&#xff0c;学习.NET Core的基础知识补遗”&#xff0c;以便接下来的阅读。 在本文将介绍如何配置类库项目支持不同的平台&#xff0c;并为不同的平台进行兼…

常用的推荐算法小结

转载自 常用的推荐算法小结推荐系统的必然 互联网发展到现阶段&#xff0c;信息已经不是匮乏&#xff0c;而是爆炸。所以良好的用户体验就是把用户喜欢的&#xff0c;感兴趣的从大量的数据中筛选出来&#xff0c;再呈现给用户&#xff0c;实现千人千面的效果。 所以推荐系统的…

.NET 4.6.2正式发布带来众多特性

虽然大多数人的注意力都集中在.NET Core上&#xff0c;但与原来的.NET Framework相关的工作还在继续。.NET Framework 4.6.2正式版已于近日发布&#xff0c;其重点是安全和WinForms/WPF/ASP.NET/WCF相关的特性,英文博客文章https://blogs.msdn.microsoft.com/dotnet/2016/08/02…

推荐算法-关联分析(关联规则)

转载自 推荐算法-关联分析&#xff08;关联规则&#xff09;关联分析又称关联挖掘&#xff0c;就是在交易数据、关系数据或其他信息载体中&#xff0c;查找存在于项目集合或对象集合之间的频繁模式、关联、相关性或因果结构。或者说&#xff0c;关联分析是发现交易数据库中不…

动态网页开发基础【笔记】

一、C/S结构和B/S结构1.C/S&#xff08;Client/Server&#xff09;:客户端服务程序&#xff0c;控制台程序&#xff0c;window应用2.B/S(Browser/Server):浏览器服务程序[java:jsp应用&#xff1b;C#:asp.net],web应用程序区别&#xff1a;C/S:客户端和服务器端都需要开发&…

ASP.NET Core 中文文档 第三章 原理(2)中间件

原文&#xff1a;Middleware作者&#xff1a;Steve Smith and Rick Anderson翻译&#xff1a;刘怡(AlexLEWIS)校对&#xff1a;许登洋(Seay) 章节&#xff1a; 什么是中间件用 IApplicationBuilder 创建中间件管道内置中间件编写中间件扩展资源 查看或下载样例代码 什么是中间件…

关联分析:FP-Growth算法

转载自 关联分析&#xff1a;FP-Growth算法关联分析又称关联挖掘&#xff0c;就是在交易数据、关系数据或其他信息载体中&#xff0c;查找存在于项目集合或对象集合之间的频繁模式、关联、相关性或因果结构。关联分析的一个典型例子是购物篮分析。通过发现顾客放入购物篮中不同…

sql server链接查询

一、连接结果集中有多个表的信息时用连接查询1.内连接:多个表根据公共列连接&#xff0c;符合条件的显示&#xff0c;不符合条件的不显示 2.外连接:多个表根据公共列连接&#xff0c;显示一个表中的所有信息&#xff0c;另个表中中符合条件的信息&#xff0c;不符合条件的用nul…

ASP.NET Core 中文文档 第三章 原理(1)应用程序启动

原文&#xff1a;Application Startup作者&#xff1a;Steve Smith翻译&#xff1a;刘怡(AlexLEWIS)校对&#xff1a;谢炀(kiler398)、许登洋(Seay) ASP.NET Core 为你的应用程序提供了处理每个请求的完整控制。Startup 类是应用程序的入口&#xff08;entry point&#xff09;…