简体   繁体   English

java 来自 Oracle 的连接池

[英]java Connection Pooling from Oracle

I'm trying to make a connection pool following this link: http://192.9.162.55/developer/onlineTraining/Programming/JDCBook/conpool.html我正在尝试通过以下链接创建连接池: http://192.9.162.55/developer/onlineTraining/Programming/JDCBook/conpool.html

I don't understand something: Somewhere in the class JDCConnectionDriver implements Driver you can find this method:我不明白的东西: 在class JDCConnectionDriver 实现驱动程序的某处,您可以找到此方法:

public static final String URL_PREFIX = "jdbc:jdc:";
public Connection connect(String url, Properties props) 
                                   throws SQLException {
    if(!url.startsWith(URL_PREFIX) {
         return null;
    }
    return pool.getConnection();
}

so, if you use mysql (for example), the url it will always start with jdbc ... so the method connect it will never return you a connection... Why is that?因此,如果您使用 mysql(例如),则 url 将始终以jdbc 开头...所以连接它的方法永远不会返回您的连接...为什么?

Also I would like to ask you which is the best connection pooling framework...另外我想问你哪个是最好的连接池框架......

so, if you use mysql (for example), the url it will always start with jdbc... so the method connect it will never return you a connection... Why is that?因此,如果您使用 mysql(例如),则 url 将始终以 jdbc 开头...所以连接它的方法永远不会返回您的连接...为什么?

This driver is specifically written to connect to a JDC Connection.此驱动程序是专门为连接到 JDC 连接而编写的。 That's why.这就是为什么。 It's looking for a url starting with jdbc:jdc: and not just jdbc: .它正在寻找从jdbc:jdc:开始的 url ,而不仅仅是jdbc:

Also I would like to ask you which is the best connection pooling framework...另外我想问你哪个是最好的连接池框架......

The most well known Connection Pooling library out there and used on many application servers and servlet containers is Apache Object Pool .最广为人知的连接池库是Apache Object Pool ,并且在许多应用程序服务器和 servlet 容器中使用。 The most common connection pooling is Apache DBCP (DataBase Connection Pooling) .最常见的连接池是Apache DBCP(数据库连接池)

Also, as stated by Rocky Triton , c3p0 is another JDBC library that included Connection and Statement Pooling.此外,正如Rocky Triton所述, c3p0是另一个包含连接和语句池的 JDBC 库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM