Java DB Conn Pool

码农软件 · 软件分类 · 数据库连接池 · 2019-09-03 18:41:24

软件介绍

Java DB Conn Pool 是一个 Java 的数据库连接池组件。

使用示例代码:

public class TestPool
{
public static void main (String[] args)
{
DataSource ds = null;
//PrintWriter log = null; //uncomment to turn on logging
try
{
//log = new PrintWriter(new FileWriter("dblog"), true); //uncomment to turn on logging
Properties p = new Properties();
p.setProperty("logLevel", "1"); //debug = 4, info = 3, warn = 2, error = 1, fatal = 0
p.setProperty("autoCommit", "false");
p.setProperty("description", "Oracle");
p.setProperty("driverClass", "oracle.jdbc.driver.OracleDriver");
p.setProperty("maxCount", "2");
p.setProperty("minCount", "1");
p.setProperty("user", "test");
p.setProperty("password", "test");
p.setProperty("url", "jdbc:oracle:thin:@127.0.0.1:1565:test");
p.setProperty("loginTimeout", "0"); //in seconds
p.setProperty("holdTimeout", "1000"); //in seconds
p.setProperty("waitTimeout", "10000"); //in milliseconds
p.setProperty("checkQuery", "select SYSDATE from dual");
p.setProperty("statementCacheSize", "10");

//ds = new RPDataSource(p, log); //use this instead of the next line to turn on logging
ds = new RPDataSource(p);
Connection con = ds.getConnection();
Statement s = con.createStatement();
ResultSet rs = s.executeQuery("select SYSDATE from dual");
if (rs.next())
{
System.out.println (rs.getString(1));
}
rs.close();
s.close();
con.close();
con = ds.getConnection();
s = con.createStatement();
rs = s.executeQuery ("select SYSDATE from dual");
if (rs.next())
{
System.out.println (rs.getString(1));
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
RPDataSource rp = (RPDataSource)ds;
rp.destroy();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
}

本文地址:https://codercto.com/soft/d/13807.html

Algorithms to Live By

Algorithms to Live By

Brian Christian、Tom Griffiths / Henry Holt and Co. / 2016-4-19 / USD 30.00

A fascinating exploration of how insights from computer algorithms can be applied to our everyday lives, helping to solve common decision-making problems and illuminate the workings of the human mind ......一起来看看 《Algorithms to Live By》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

在线进制转换器
在线进制转换器

各进制数互转换器

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码