提交 2aa71513 authored 作者: Thomas Mueller's avatar Thomas Mueller

JaQu: a database object can now also be created using a DataSource. Issue 227.

上级 966c23c9
......@@ -15,6 +15,7 @@ import java.sql.Statement;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import javax.sql.DataSource;
import org.h2.jaqu.util.Utils;
import org.h2.jaqu.util.WeakIdentityHashMap;
......@@ -64,6 +65,21 @@ public class Db {
}
}
/**
* Create a new database instance using a data source. This method is fast,
* so that you can always call open() / close() on usage.
*
* @param ds the data source
* @return the database instance.
*/
public static Db open(DataSource ds) {
try {
return new Db(ds.getConnection());
} catch (SQLException e) {
throw convert(e);
}
}
public static Db open(String url, String user, char[] password) {
try {
Properties prop = new Properties();
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论