资源简介
web项目数据库连接样例web项目数据库连接样例web项目数据库连接样例web项目数据库连接样例web项目数据库连接样例
代码片段和文件信息
/*
* AbstractDataSource.java 2009-4-1
*
* Copyright 2005-2012 IJAVA Tech Inc. All rights reserved.
*/
package org.ipos.sql;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;
import javax.sql.DataSource;
/**
* A AbstractDataSource
*
* Specification:
*
*
* @sees
* @author Steven Chen
* @since 1.0
* @version 1.0 2009-4-1
*/
public abstract class AbstractDataSource implements DataSource {
protected DataSource internalDataSource;
protected ConfigInfo configInfo;
private InputStream config;
public AbstractDataSource() {
initDataSource();
}
public AbstractDataSource(InputStream config) {
this.config = config;
initDataSource();
}
/*
* (non-Javadoc)
*
* @see javax.sql.DataSource#getConnection()
*/
public Connection getConnection() throws SQLException {
return internalDataSource.getConnection();
}
/*
* (non-Javadoc)
*
* @see javax.sql.DataSource#getConnection(java.lang.String
* java.lang.String)
*/
public Connection getConnection(String username String password)
throws SQLException {
return internalDataSource.getConnection(username password);
}
/*
* (non-Javadoc)
*
* @see javax.sql.CommonDataSource#getLogWriter()
*/
public PrintWriter getLogWriter() throws SQLException {
return internalDataSource.getLogWriter();
}
/*
* (non-Javadoc)
*
* @see javax.sql.CommonDataSource#getLoginTimeout()
*/
public int getLoginTimeout() throws SQLException {
return internalDataSource.getLoginTimeout();
}
/*
* (non-Javadoc)
*
* @see javax.sql.CommonDataSource#setLogWriter(java.io.PrintWriter)
*/
public void setLogWriter(PrintWriter out) throws SQLException {
internalDataSource.setLogWriter(out);
}
/*
* (non-Javadoc)
*
* @see javax.sql.CommonDataSource#setLoginTimeout(int)
*/
public void setLoginTimeout(int seconds) throws SQLException {
internalDataSource.setLoginTimeout(seconds);
}
/*
* (non-Javadoc)
*
* @see java.sql.Wrapper#isWrapperFor(java.lang.Class)
*/
public boolean isWrapperFor(Class> iface) throws SQLException {
return internalDataSource.isWrapperFor(iface);
}
/*
* (non-Javadoc)
*
* @see java.sql.Wrapper#unwrap(java.lang.Class)
*/
public T unwrap(Class iface) throws SQLException {
return internalDataSource.unwrap(iface);
}
abstract protected void initDataSource();
public static void main(String[] args) {
AbstractDataSource a = new JNDIDataSource();
a.initConfig();
}
protected void initConfig() {
try {
if (config == null)
config = AbstractDataSource.class
.getResourceAsStream(“/dbconfig.properties“);
Properties proper = new Properties();
proper.load(config);
String vendor = proper.getProperty(“vendor“);
String url = pr
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 3772 2011-09-28 20:18 sql\AbstractDataSource.java
文件 1976 2009-05-16 10:06 sql\DriverManagerDataSource.java
文件 1037 2009-05-16 10:06 sql\JdbcTemplate.java
文件 931 2009-05-16 10:06 sql\JNDIDataSource.java
文件 1121 2009-05-16 10:06 sql\PlatformDataSourceFactory.java
目录 0 2011-09-28 20:20 sql
----------- --------- ---------- ----- ----
8837 6
- 上一篇:一级圆柱齿轮减速器装配
- 下一篇:PacketMonitor.rar
评论
共有 条评论