public class ConnectionManager {
	//对象池
	private static GenericKeyedObjectPool connectionPool = null;
	//相关配置
	private static Properties configContent = null;
	
	//私有构造函数
	private ConnectionManager()
	{
		//do something
	}
	//初始化
	static
	{
		init();
	}
	
	/**
	 * 获得数据库连接信息
	 * @param type
	 * @param dataBaseURL
	 *   [数据库类别：dataBaseURL值的写法]
	 *   [Oracle: jdbc:oracle:thin:@127.0.0.1:1521:orcl]
	 *   [SQLServer: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test]
	 *   [MySQL: jdbc:mysql://127.0.0.1:3306/test]
	 *   [PostgreSQL: jdbc:postgresql://127.0.0.1:5432/postgis]
	 *   [SQLite: jdbc:sqlite://d:/test.db]
	 *   [Mongo: jdbc:mongo://127.0.0.1:29847/test]
	 *   [Access: e://student.mdb]
	 * @param userName
	 * @param passWord
	 * @return ConnectionInfo
	 */
	public static <T extends Enum<T> & IDataSource> ConnectionInfo getConnectionInfo(T type,String dataBaseURL,String userName,String passWord)
	{
		String key = dataBaseURL+"+"+userName+"+"+passWord;
		DBConnectionFactory.getIConnection(key, type);
		return new ConnectionInfo(key,type);
	}
	/**
	 * 获取数据库连接对象
	 * @param type
	 * @param dataBaseURL
	 *   [数据库类别：dataBaseURL值的写法]
	 *   [Oracle: jdbc:oracle:thin:@127.0.0.1:1521:orcl]
	 *   [SQLServer: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test]
	 *   [MySQL: jdbc:mysql://127.0.0.1:3306/test]
	 *   [PostgreSQL: jdbc:postgresql://127.0.0.1:5432/postgis]
	 *   [SQLite: jdbc:sqlite://d:/test.db]
	 *   [Mongo: jdbc:mongo://127.0.0.1:29847/test]
	 *   [Access: e://student.mdb]
	 * @param userName
	 * @param passWord
	 * @return ConnectionObject
	 */
	public static <T extends Enum<T> & IDataSource> ConnectionObject borrowConnectionObject(T type,String dataBaseURL,String userName,String passWord)
	{
		String key = dataBaseURL+"+"+userName+"+"+passWord;
		
		ConnectionObject connobject = null;
		try 
		{
			connobject = (ConnectionObject) connectionPool.borrowObject(key);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_GetConnectionFromPool, e);
			return null;
		}
		return connobject;
	}
	/**
	 * 从连接池中拿到一个连接对象
	 * WARNING:需要归还！调用returnConnectionObject
	 * @param connInfo
	 * @return ConnectionObject
	 */
	public static <T extends Enum<T> & IDataSource> ConnectionObject borrowConnectionObject(ConnectionInfo connInfo)
	{
		String key = connInfo.getKey();
		ConnectionObject connobject = null;
		try 
		{
			connobject = (ConnectionObject) connectionPool.borrowObject(key);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_GetConnectionFromPool, e);
			return null;
		}
		return connobject;
	}
	/**
	 * 归还数据库连接对象
	 * @param conn
	 * @return boolean
	 */
	public static boolean returnConnectionObject(ConnectionObject conn)
	{
		try 
		{
			connectionPool.returnObject(conn.getKey(),conn);
			return true;
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_ReturnObject, e);
			return false;
		}
	}
	/**
	 * 根据配置信息初始化连接池，配置文件路径./config/ConnectionPool.properties
	 * @param type
	 * @param dataBaseURL
	 *   [数据库类别：dataBaseURL值的写法]
	 *   [Oracle: jdbc:oracle:thin:@127.0.0.1:1521:orcl]
	 *   [SQLServer: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test]
	 *   [MySQL: jdbc:mysql://127.0.0.1:3306/test]
	 *   [PostgreSQL: jdbc:postgresql://127.0.0.1:5432/postgis]
	 *   [SQLite: jdbc:sqlite://d:/test.db]
	 *   [Mongo: jdbc:mongo://127.0.0.1:29847/test]
	 *   [Access: e://student.mdb]
	 * @param userName
	 * @param passWord
	 */
	public static <T extends Enum<T> & IDataSource> void initConnectionPoolByConfigure(T type,String dataBaseURL,String userName,String passWord)
	{
		String key = dataBaseURL+"+"+userName+"+"+passWord;
		DBConnectionFactory.getIConnection(key, type);
		
		ConnectionObject connobject = null;
		int size = Integer.parseInt(configContent.getProperty("minIdle"));
		for(int i=0;i<size;i++)
		{
			try 
			{
				connobject = (ConnectionObject) connectionPool.borrowObject(key);
				connectionPool.returnObject(key, connobject);
				
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				DBCException.logException(DBCException.E_ConnectionPoolInit, e);
			}
		}
	}
	
	//对象池初始化
	private static void init()
	{
		KeyedPoolableObjectFactory fac = (KeyedPoolableObjectFactory) new DBConnectionFactory();
		//读取配置信息
		configContent = readConfig();
		GenericKeyedObjectPool.Config config = new GenericKeyedObjectPool.Config();   
		config.maxTotal = 300;//池中对象总数
		if(configContent.getProperty("maxTotal") != null && !"".equals(configContent.getProperty("maxTotal")))
		{
			config.maxTotal = Integer.parseInt(configContent.getProperty("maxTotal"));
		}
		
		config.maxActive = 100;//每个键分配的最大对象数 
		if(configContent.getProperty("maxActive") != null && !"".equals(configContent.getProperty("maxActive")))
		{
			config.maxActive = Integer.parseInt(configContent.getProperty("maxActive"));
		}
		
		config.maxWait = 10 * 1000L;//获取对象的等待时间
		config.testOnBorrow = true;//借出对象时监测对象是否可用
		config.maxIdle = 30;//最大空闲对象数
		if(configContent.getProperty("maxIdle") != null && !"".equals(configContent.getProperty("maxIdle")))
		{
			config.maxIdle = Integer.parseInt(configContent.getProperty("maxIdle"));
		}
		
		config.minIdle = 10;//最小空闲对象数
		if(configContent.getProperty("minIdle") != null && !"".equals(configContent.getProperty("minIdle")))
		{
			config.minIdle = Integer.parseInt(configContent.getProperty("minIdle"));
		}
		
		config.minEvictableIdleTimeMillis = 1000L*60L*10L;//空闲对象清理之前在池中闲置的最小时间
		if(configContent.getProperty("minEvictableIdleTimeMillis") != null && !"".equals(configContent.getProperty("minEvictableIdleTimeMillis")))
		{
			config.minEvictableIdleTimeMillis = Integer.parseInt(configContent.getProperty("minEvictableIdleTimeMillis"));
		}
		
		config.timeBetweenEvictionRunsMillis = 1000L*60L*30L;//空闲对象清理运行周期
		if(configContent.getProperty("timeBetweenEvictionRunsMillis") != null && !"".equals(configContent.getProperty("timeBetweenEvictionRunsMillis")))
		{
			config.timeBetweenEvictionRunsMillis = Integer.parseInt(configContent.getProperty("timeBetweenEvictionRunsMillis"));
		}
		
		config.whenExhaustedAction = GenericKeyedObjectPool.WHEN_EXHAUSTED_GROW;//当达到最大容量时直接创建
		
		connectionPool = new GenericKeyedObjectPool(fac, config);  
	}
	//读取配置文件
	private static Properties readConfig()
	{
		Properties configParam = new Properties();
		try 
		{
			configParam.load(DataBaseManager.class.getClassLoader().getResourceAsStream("config/ConnectionPool.properties"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_ReadConfig, e);
		}
		return configParam;
	}
	
	//==========================================================================
	/**
	 * 内部静态类
	 * @author SHAO Gaige
	 *
	 */
	public static class ConnectionInfo{
		//type
		private IDataSource sourceType;
		//key
		private String key;
		
		private ConnectionInfo(String key,IDataSource sourceType){
			this.key = key;
			this.sourceType = sourceType;
		}
		/**
		 * 获取IDataSource操作接口
		 * @return IDataSource
		 */
		public IDataSource getIDataSource() {
			return sourceType;
		}
		/**
		 * 获取数据库连接标识
		 * @return String
		 */
		public String getKey() {
			return key;
		}
	}
	//==========================================================================

}
 public class ConnectionObject {
	//数据库连接
	private Connection connection = null;
	//连接标识
	private String key;
	//构造函数
	public ConnectionObject(String key,Connection connection)
	{
		if(key!=null && connection!=null)
		{
			this.key = key;
			this.connection = connection;
		}
	}
	/**
	 * 获取java.sql.Connection对象
	 * @return Connection
	 */
	public Connection getConnection() {
		return connection;
	}
	/**
	 * 获取数据库连接标识
	 * @return String
	 */
	public String getKey() {
		return key;
	}
}
 public class DataBase implements IDataBase{
	
	//数据库连接
	protected ConnectionInfo connInfo = null;
	
	/**
	 * 无参构造函数
	 */
	public DataBase()
	{
		
	}
	/**
	 * 构造函数
	 * @param conn
	 * @throws Exception
	 */
	public DataBase(ConnectionInfo connInfo)
	{
		if(connInfo != null)
		{
			this.connInfo = connInfo;
		}
		else
		{
			try
			{
				throw new Exception("Error: conninfo is null, DataBase construct fail !!!");
			}catch(Exception e){
				e.printStackTrace();
				DBCException.logException(DBCException.E_DataBaseInit, e);
			}
		}
	}
	/**
	 * 获取数据库连接字符串信息
	 * @return String
	 */
	public String getConnectionString(){
		return connInfo.getKey();	
	}
    /**
     * 设置数据库连接字符串信息
     * @param connInfo
     */
	public void setConnInfo(ConnectionInfo connInfo) {
		this.connInfo = connInfo;
	}
	/**
	 * 新建表
	 * @param sql
	 * @return boolean
	 */
	@Override
	public boolean exeSQLCreate(String sql)
	{
		ConnectionObject conn = null;
		Statement stat = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			stat.execute(sql);
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(stat != null)
			{
				try 
				{
					stat.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exePreparedSQLCreate(String sql, PreparedParam preparedParam) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		PreparedStatement preStmt = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			preStmt = conn.getConnection().prepareStatement(sql);
			SQLPreparedParamUtil.setSQLPreparedParam(preStmt, preparedParam);
			preStmt.execute();
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(preStmt != null)
			{
				try 
				{
					preStmt.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	
	@Override
	public SQLResultSet exeSQLSelect(String sql)
	{
		ConnectionObject conn = null;
		Statement stat = null;
		ResultSet rs = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			rs = stat.executeQuery(sql);
			SQLResultSet r = ResultSetUtil.getSQLResultSet(rs);
			return r;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return null;
		}
		finally
		{
			try 
			{
				if(rs != null)
				{
					rs.close();
				}
				if(stat != null)
				{
					stat.close();
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public SQLResultSet exeSQLSelect(String sql, int start, int count) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		Statement stat = null;
		ResultSet rs = null;
		try
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			rs = stat.executeQuery(sql);
			SQLResultSet r = ResultSetUtil.getSQLResultSet(rs,start,count);
			return r;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return null;
		}
		finally
		{
			try 
			{
				if(rs != null)
				{
					rs.close();
				}
				if(stat != null)
				{
					stat.close();
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public SQLResultSet exePreparedSQLSelect(String sql,PreparedParam preparedParam) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		PreparedStatement preStmt = null;
		ResultSet rs = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			preStmt = conn.getConnection().prepareStatement(sql);
			SQLPreparedParamUtil.setSQLPreparedParam(preStmt, preparedParam);
			rs = preStmt.executeQuery();
			SQLResultSet r = ResultSetUtil.getSQLResultSet(rs);
			return r;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return null;
		}
		finally
		{
			try 
			{
				if(rs != null)
				{
					rs.close();
				}
				if(preStmt != null)
				{
					preStmt.close();
				}
			}catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public SQLResultSet exePreparedSQLSelect(String sql, PreparedParam preparedParam, int start, int count) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		PreparedStatement preStmt = null;
		ResultSet rs = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			preStmt = conn.getConnection().prepareStatement(sql);
			SQLPreparedParamUtil.setSQLPreparedParam(preStmt, preparedParam);
			rs = preStmt.executeQuery();
			SQLResultSet r = ResultSetUtil.getSQLResultSet(rs,start,count);
			return r;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return null;
		}
		finally
		{
			try 
			{
				if(rs != null)
				{
					rs.close();
				}
				if(preStmt != null)
				{
					preStmt.close();
				}
			}catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exeSQLDrop(String sql) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		Statement stat = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			stat.execute(sql);
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(stat != null)
			{
				try {
					stat.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exePreparedSQLDrop(String sql, PreparedParam preparedParam) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		PreparedStatement preStmt = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			preStmt = conn.getConnection().prepareStatement(sql);
			SQLPreparedParamUtil.setSQLPreparedParam(preStmt, preparedParam);
			preStmt.execute();
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(preStmt != null)
			{
				try 
				{
					preStmt.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exeSQLAlter(String sql) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		Statement stat = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			stat.execute(sql);
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(stat != null)
			{
				try 
				{
					stat.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exePreparedSQLAlter(String sql, PreparedParam preparedParam) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		PreparedStatement preStmt = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			preStmt = conn.getConnection().prepareStatement(sql);
			SQLPreparedParamUtil.setSQLPreparedParam(preStmt, preparedParam);
			preStmt.execute();
			
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(preStmt != null)
			{
				try 
				{
					preStmt.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exeSQLUpdate(String sql) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		Statement stat = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			stat.executeUpdate(sql);
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(stat != null)
			{
				try 
				{
					stat.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exePreparedSQLUpdate(String sql, PreparedParam preparedParam) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		PreparedStatement preStmt = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			preStmt = conn.getConnection().prepareStatement(sql);
			SQLPreparedParamUtil.setSQLPreparedParam(preStmt, preparedParam);
			preStmt.executeUpdate();
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(preStmt != null)
			{
				try 
				{
					preStmt.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public int exeSQLInsert(String sql) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		Statement stat = null;
		ResultSet rs = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			//stat.executeUpdate(sql);
			//int autoGeneratedKeys = 0;
			int f = stat.executeUpdate(sql);
			//rs = stat.getGeneratedKeys();
			//if(rs.next())
			//{
				//autoGeneratedKeys = rs.getInt(1);
			//}
			
			return f;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return 0;
		}
		finally
		{
			try 
			{
				if(rs != null)
				{
					rs.close();
				}
				if(stat != null)
				{
					stat.close();
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public int exePreparedSQLInsert(String sql, PreparedParam preparedParam) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		PreparedStatement preStmt = null;
		ResultSet rs = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			preStmt = conn.getConnection().prepareStatement(sql,Statement.RETURN_GENERATED_KEYS);
			SQLPreparedParamUtil.setSQLPreparedParam(preStmt, preparedParam);
			int f = preStmt.executeUpdate();
			//rs = preStmt.getGeneratedKeys();
			return f;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return 0;
		}
		finally
		{
			try 
			{
				if(rs != null)
				{
					rs.close();
				}
				if(preStmt != null)
				{
					preStmt.close();
				}
			}catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exeSQLDelete(String sql) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		Statement stat = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			stat.executeUpdate(sql);
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(stat != null)
			{
				try
				{
					stat.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exePreparedSQLDelete(String sql, PreparedParam preparedParam) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		PreparedStatement preStmt = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			preStmt = conn.getConnection().prepareStatement(sql);
			SQLPreparedParamUtil.setSQLPreparedParam(preStmt, preparedParam);
			preStmt.executeUpdate();
			return true;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(preStmt != null)
			{
				try 
				{
					preStmt.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exeBatchSQL(List<String> sqls) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		Statement stat = null;
		try
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			if(sqls!=null && sqls.size()>0)
			{
				int size = sqls.size();
				for(int i=0;i<size;i++)
				{
					stat.addBatch(sqls.get(i));
				}
				stat.executeBatch();
			    return true;
			}
			else
			{
				return false;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(stat != null)
			{
				try 
				{
					stat.close();
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exePreparedBatchSQL(String sql,List<PreparedParam> preparedParams) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		PreparedStatement preStmt = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			preStmt = conn.getConnection().prepareStatement(sql);
			if(preparedParams!=null && preparedParams.size()>0)
			{
				int size = preparedParams.size();
				for(int i=0;i<size;i++)
				{
					PreparedParam preparedParam = preparedParams.get(i);
					SQLPreparedParamUtil.setSQLPreparedParam(preStmt, preparedParam);
					preStmt.addBatch();
				}
				preStmt.executeBatch();
				return true;
			}
			else
			{
				return false;
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return false;
		}
		finally
		{
			if(preStmt != null)
			{
				try 
				{
					preStmt.close();
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public boolean exeMixedBatchSQL(MixedBatchSQL mixedBatchSQL) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		if(mixedBatchSQL != null)
		{
			String pSQL = mixedBatchSQL.getPreparedSQL();
			PreparedStatement preStmt = null;
			try 
			{
				conn = ConnectionManager.borrowConnectionObject(connInfo);
				preStmt = conn.getConnection().prepareStatement(pSQL);
				List<PreparedParam> preparedParams = mixedBatchSQL.getPreparedParams();
				if(preparedParams!=null && preparedParams.size()>0)
				{
					int size = preparedParams.size();
					for(int i=0;i<size;i++)
					{
						PreparedParam preparedParam = preparedParams.get(i);
						SQLPreparedParamUtil.setSQLPreparedParam(preStmt, preparedParam);
						preStmt.addBatch();
					}
					int size2 = mixedBatchSQL.getStaticSQLCount();
					for(int j=0;j<size2;j++)
					{
						preStmt.addBatch(mixedBatchSQL.getStaticSQL(j));
					}
					preStmt.executeBatch();
					return true;
				}
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				DBCException.logException(DBCException.E_SQL, e);
			}
			finally
			{
				if(preStmt != null)
				{
					try 
					{
						preStmt.close();
					} catch (Exception e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
				if(conn != null)
				{
					ConnectionManager.returnConnectionObject(conn);
				}
			}
		}
		return false;
	}
	@Override
	public boolean exeTransactionSQL(List<String> sqls) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		Statement stat = null;
		try 
		{
			if(sqls!=null && sqls.size()>0)
			{
				conn = ConnectionManager.borrowConnectionObject(connInfo);
				conn.getConnection().setAutoCommit(false);
			    stat = conn.getConnection().createStatement();
			    int size = sqls.size();
			    for(int i=0;i<size;i++)
			    {
			    	stat.executeUpdate(sqls.get(i));
			    }
			    
			    conn.getConnection().commit();
			    return true;
			}
			return false;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			try {
				conn.getConnection().rollback();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
				DBCException.logException(DBCException.E_SQL_RollBack, e);
			}
			return false;
		}
		finally
		{
			try 
			{
				if(stat != null)
				{
					stat.close();
				}
				conn.getConnection().setAutoCommit(true);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				DBCException.logException(DBCException.E_ConnectionSetAutoCommit, e);
			}
			finally
			{
				if(conn != null)
				{
					ConnectionManager.returnConnectionObject(conn);
				}
			}
		}
		
		
	}
	@Override
	public boolean exeTransactionPreparedSQL(Map<String, PreparedParam> psqls) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		try 
		{
			if(psqls!=null && psqls.size()>0)
			{
				conn = ConnectionManager.borrowConnectionObject(connInfo);
				conn.getConnection().setAutoCommit(false);
				for(String sql:psqls.keySet())
				{
					PreparedParam param = psqls.get(sql);
					if(param == null)
					{
						boolean f = exeSQLUpdate(sql);
						if(!f)
						{
							return false;
						}
					}
					else
					{
						boolean f = exePreparedSQLUpdate(sql, param);
						if(!f)
						{
							return false;
						}
					}
				}
				conn.getConnection().commit();
				return true;
			}
			return false;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			try {
				conn.getConnection().rollback();
			} catch (SQLException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
				DBCException.logException(DBCException.E_SQL_RollBack, e);
			}
			return false;
		}
		finally
		{
			try {
				conn.getConnection().setAutoCommit(true);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				DBCException.logException(DBCException.E_ConnectionSetAutoCommit, e);
			}
			finally
			{
				if(conn != null)
				{
					ConnectionManager.returnConnectionObject(conn);
				}
			}
		}
		
	}
	@Override
	public SQLResultSet getMetaData(String sql) {
		// TODO Auto-generated method stub
		ConnectionObject conn = null;
		Statement stat = null;
		ResultSet rs = null;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			rs = stat.executeQuery(sql);
			ResultSetMetaData resultMetaData = rs.getMetaData();
			List<SQLRow> resultSet = new ArrayList<SQLRow>();
			int size = resultMetaData.getColumnCount();
			//获取所有列名称
			for(int i=1;i<=size;i++)
			{
				Map<String,Value> keyValue = new LinkedHashMap<String,Value>();
				keyValue.put("name", new Value().setString_value(resultMetaData.getColumnName(i)));
				keyValue.put("label", new Value().setString_value(resultMetaData.getColumnLabel(i)));
				keyValue.put("typename", new Value().setString_value(resultMetaData.getColumnTypeName(i)));
				keyValue.put("type", new Value().setInt_value(resultMetaData.getColumnType(i)));
				SQLRow row = new SQLRow(keyValue);
				resultSet.add(row);
			}
			
			SQLResultSet r = new SQLResultSet(resultSet);
			return r;
			
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return null;
		}
		finally
		{
			try 
			{
				if(rs != null)
				{
					rs.close();
				}
				if(stat != null)
				{
					stat.close();
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				//e.printStackTrace();
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}
	@Override
	public long getCount(String sql) {
		// TODO Auto-generated method stub
		//处理sql
		String sql_c = "select count(*) from (";
		sql_c += sql +") a1_databaseconnection";
		ConnectionObject conn = null;
		Statement stat = null;
		ResultSet rs = null;
		long count = 0;
		try 
		{
			conn = ConnectionManager.borrowConnectionObject(connInfo);
			stat = conn.getConnection().createStatement();
			rs = stat.executeQuery(sql_c);
			if(rs.next())
			{
				count = (long) rs.getDouble(1);
			}
			return count;
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			DBCException.logException(DBCException.E_SQL, e);
			return 0;
		}
		finally
		{
			try 
			{
				if(rs != null)
				{
					rs.close();
				}
				if(stat != null)
				{
					stat.close();
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			if(conn != null)
			{
				ConnectionManager.returnConnectionObject(conn);
			}
		}
	}

}
 public enum DataBaseEnum implements IDataSource {
	
	/**
	 * Oracle
	 */
	 ORACLE{
		 
		@Override
		public String getDataBaseName() {
			// TODO Auto-generated method stub
			return "Oracle";
		}

		@Override
		public IConnection getConnection() {
			// TODO Auto-generated method stub
			return new OracleDataBaseConnection();
		}

		@SuppressWarnings("unchecked")
		@Override
		public <T extends DataBase> Class<T> getDataBase() {
			// TODO Auto-generated method stub
			return (Class<T>) OracleDataBase.class;
		}
		
	},
	/**
	 * MySQL
	 */
	MYSQL{

		@Override
		public String getDataBaseName() {
			// TODO Auto-generated method stub
			return "MySQL";
		}

		@Override
		public IConnection getConnection() {
			// TODO Auto-generated method stub
			return new MySQLDataBaseConnection();
		}

		@SuppressWarnings("unchecked")
		@Override
		public <T extends DataBase> Class<T> getDataBase() {
			// TODO Auto-generated method stub
			return (Class<T>) MySQLDataBase.class;
		}

	
	},
	/**
	 * SQLServer
	 */
	SQLSERVER{

		@Override
		public String getDataBaseName() {
			// TODO Auto-generated method stub
			return "SQLServer";
		}

		@Override
		public IConnection getConnection() {
			// TODO Auto-generated method stub
			return new SQLServerDataBaseConnection();
		}

		@SuppressWarnings("unchecked")
		@Override
		public <T extends DataBase> Class<T> getDataBase() {
			// TODO Auto-generated method stub
			return (Class<T>) SQLServerDataBase.class;
		}
	},
	/**
	 * SQLite
	 */
	SQSLITE{

		@Override
		public String getDataBaseName() {
			// TODO Auto-generated method stub
			return "SQLite";
		}

		@Override
		public IConnection getConnection() {
			// TODO Auto-generated method stub
			return new SQLiteDataBaseConnection();
		}

		@SuppressWarnings("unchecked")
		@Override
		public <T extends DataBase> Class<T> getDataBase() {
			// TODO Auto-generated method stub
			return (Class<T>) SQLiteDataBase.class;
		}
	
	},
	/**
	 * PostgreSQL
	 */
	POSTGRESQL{

		@Override
		public String getDataBaseName() {
			// TODO Auto-generated method stub
			return "PostgreSQL";
		}

		@Override
		public IConnection getConnection() {
			// TODO Auto-generated method stub
			return new PostgreSQLDataBaseConnection();
		}

		@SuppressWarnings("unchecked")
		@Override
		public <T extends DataBase> Class<T> getDataBase() {
			// TODO Auto-generated method stub
			return (Class<T>) PostgreSQLDataBase.class;
		}
	
	},
	/**
	 * MongoDB
	 */
	MONGODB{

		@Override
		public String getDataBaseName() {
			// TODO Auto-generated method stub
			return "MongoDB";
		}

		@Override
		public IConnection getConnection() {
			// TODO Auto-generated method stub
			return new MongoDataBaseConnection();
		}

		@SuppressWarnings("unchecked")
		@Override
		public <T extends DataBase> Class<T> getDataBase() {
			// TODO Auto-generated method stub
			return (Class<T>) MongoDataBase.class;
		}
	},
	/**
	 * Access
	 */
	ACCESS{

		@Override
		public String getDataBaseName() {
			// TODO Auto-generated method stub
			return "Access";
		}

		@Override
		public IConnection getConnection() {
			// TODO Auto-generated method stub
			return new AccessDataBaseConnection();
		}

		@SuppressWarnings("unchecked")
		@Override
		public <T extends DataBase> Class<T> getDataBase() {
			// TODO Auto-generated method stub
			return (Class<T>) AccessDataBase.class;
		}
	};

}
 public class DataBaseManager {
	
	//私有构造函数
	private DataBaseManager()
	{
		//do something
	}
	/**
	 * 获取数据库对象
	 * @param type
	 * @param dataBaseURL
	 *   [数据库类别：dataBaseURL值的写法]
	 *   [Oracle: jdbc:oracle:thin:@127.0.0.1:1521:orcl]
	 *   [SQLServer: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test]
	 *   [MySQL: jdbc:mysql://127.0.0.1:3306/test]
	 *   [PostgreSQL: jdbc:postgresql://127.0.0.1:5432/postgis]
	 *   [SQLite: jdbc:sqlite://d:/test.db]
	 *   [Mongo: jdbc:mongo://127.0.0.1:29847/test]
	 *   [Access: e://student.mdb]
	 * @param userName
	 * @param passWord
	 * @return DataBase
	 */
	public static <T extends Enum<T> & IDataSource> DataBase getDataBase(T type,String dataBaseURL,String userName,String passWord)
	{
		ConnectionInfo connInfo = ConnectionManager.getConnectionInfo(type, dataBaseURL, userName, passWord);
		DataBase dataBase = GodTool.newInstanceDataBase(connInfo);
		return dataBase;
	}
	/**
	 * 由数据库连接信息获取数据库对象
	 * @param connInfo
	 * @return DataBase
	 */
	public static DataBase getDataBase(ConnectionInfo connInfo)
	{
		DataBase dataBase = GodTool.newInstanceDataBase(connInfo);
		return dataBase;
	}

} public class MixedBatchSQL {
	
	private String preparedSQL = null;
	
	private List<PreparedParam> preparedParams = new ArrayList<PreparedParam>();
	
	private List<String> sql = new ArrayList<String>();
	/**
	 * 增加静态sql语句
	 * @param sql
	 */
	public void addStaticBatchSQL(String sql)
	{
		this.sql.add(sql);
	}
	/**
	 * 获取静态sql语句的数量
	 * @return int
	 */
	public int getStaticSQLCount()
	{
		return this.sql.size();
	}
	/**
	 * 根据索引获取某个静态sql语句
	 * @param index
	 * @return String
	 */
	public String getStaticSQL(int index)
	{
		if(index>=getStaticSQLCount() || index<0)
		{
			return null;
		}
		return this.sql.get(index);
	}
	/**
	 * 设置PreparedSQL语句和参数
	 * @param sql
	 * @param preparedParams
	 */
	public void setPreparedBatchSQL(String sql,List<PreparedParam> preparedParams)
	{
		if(sql!=null && preparedParams!=null)
		{
			this.preparedSQL = sql;
		    this.preparedParams = preparedParams;
		}
		
	}
	/**
	 * 获取PreparedSQL
	 * @return String
	 */
	public String getPreparedSQL() {
		return preparedSQL;
	}
	/**
	 * 获取PreparedSQL的参数
	 * @return List<PreparedParam>
	 */
	public List<PreparedParam> getPreparedParams() {
		return preparedParams;
	}
}
 public class PreparedParam {
	
	private Map<Integer,Value> row = new LinkedHashMap<Integer,Value>();
	/**
	 * 增加参数
	 * @param index
	 * @param value
	 */
	public void addParam(int index,Value value)
	{
		this.row.put(index, value);
	}
	/**
	 * 获取第几个参数
	 * @param index
	 * @return Value
	 */
	public Value getParam(int index)
	{
		return this.row.get(index);
	}
	/**
	 * 获取参数个数
	 * @return int
	 */
	public int getParamCount()
	{
		return this.row.size();
	}
	/**
	 * 获取所有的参数
	 * @return Map<Integer,Value>
	 */
	public Map<Integer,Value> getAllParam()
	{
		return this.row;
	}
}
 public class SQLColumn {
	
    private String columnName = "";
	
	private List<Value> values = new ArrayList<Value>();
	//构造函数
	public SQLColumn(String columnName,List<Value> values)
	{
		if(columnName != null && values != null)
		{
			this.columnName = columnName;
		    this.values = values;
		}
	}
	/**
	 * 获取字段名称
	 * @return String
	 */
	public String getColumnName() {
		return columnName;
	}
    /**
     * 获取本列所有的值
     * @return List<Value>
     */
	public List<Value> getValues() {
		return values;
	}
    /**
     * 给该列增加一个值
     * @param value
     */
	public void addValue(Value value){
		this.values.add(value);
	}

}
 public class SQLResultSet {
	
	private List<SQLRow> resultSet = new ArrayList<SQLRow>();
	//构造函数
	public SQLResultSet(List<SQLRow> resultSet)
	{
		if(resultSet != null)
		{
			this.resultSet = resultSet;
		}
	}
	/**
	 * 获取 行 个数
	 * @return int
	 */
	public int getRowNum()
	{
		return this.resultSet.size();
	}
	/**
	 * 获取第几行的数据,起始是 0
	 * @param i
	 * @return SQLRow
	 */
	public SQLRow getRow(int i)
	{
		if(i>=this.resultSet.size() || i<0)
		{
			return null;
		}
		return this.resultSet.get(i);
	}
	/**
	 * 获取所有的行数据
	 * @return List<SQLRow>
	 */
	public List<SQLRow> getAllRows()
	{
		return this.resultSet;
	}
	/**
	 * 获取某一列数据
	 * @param columnName
	 * @return SQLColumn
	 */
	public SQLColumn getColumn(String columnName)
	{
		if(this.resultSet.size()>0)
		{
			if(this.resultSet.get(0).containsColumn(columnName))
			{
				List<Value> values = new ArrayList<Value>();
				for(SQLRow sqlRow:this.resultSet)
				{
					Value value = sqlRow.getValue(columnName);
					values.add(value);
				}
				SQLColumn column = new SQLColumn(columnName,values);
				return column;
			}
			else
			{
				return null;
			}
		}
		else
		{
			return null;
		}
	}

}
 public class SQLRow {
	
	private Map<String,Value> row = new LinkedHashMap<String,Value>();
	/**
	 * 构造函数
	 * @param row
	 */
	public SQLRow(Map<String,Value> row)
	{
		if(row != null)
		{
			this.row = row;
		}
	}
	/**
	 * 获取某个字段的值
	 * @param columnName
	 * @return Value
	 */
	public Value getValue(String columnName)
	{
		Value v = this.row.get(columnName);
		if(v != null)
		{
			return v;
		}
		else
		{
			v = this.row.get(columnName.toLowerCase());
			if(v != null)
			{
				return v;
			}
			else
			{
				return this.row.get(columnName.toUpperCase());
			}
		}
		
	}
	/**
	 * 获取字段个数
	 * @return int
	 */
	public int getCount()
	{
		return this.row.size();
	}
	/**
	 * 获取所有的字段名称
	 * @return Set<String>
	 */
	public Set<String> getAllColumnName()
	{
		return this.row.keySet();
	}
	/**
	 * 获取所有的字段值
	 * @return Collection<Value>
	 */
	public Collection<Value> getAllValue()
	{
		return this.row.values();
	}
	/**
	 * 是否包含某个字段
	 * @param columnName
	 * @return boolean
	 */
	public boolean containsColumn(String columnName)
	{
		return this.row.containsKey(columnName);
	}
	/**
	 * 获取整列数据
	 * @return Map<String,Value>
	 */
	public Map<String,Value> getRow()
	{
		return this.row;
	}

}
 public class Value {
	
	private String string_value = "";
	
	private int int_value = 0;
	
	private long long_value = 0;
	
	private double double_value = 0;
	
	private float float_value = 0;
	
	private boolean boolean_value = false;
	
	private BigDecimal bigdecimal_value;
	
	private Blob blob_value = null;
	
	private Clob clob_value = null;
	
	private byte byte_value;
	
	private byte[] bytes_value;
	
	private Date date_value;
	
	private Time time_value;
	
	private Object object_value;
	
	private int dataType = 0;
	
	public Value()
	{
		
	}
	
	public Value(int type)
	{
		this.dataType = type;
	}
	
	public int getDataType() {
		return dataType;
	}

	public String getString_value() {
		return string_value;
	}

	public Value setString_value(String string_value) {
		this.string_value = string_value;
		if(this.dataType == 0){
			this.dataType = Types.VARCHAR;
		}
		return this;
	}
	
	public boolean isStringValue() {
		if(this.dataType==Types.CHAR || this.dataType==Types.VARCHAR || this.dataType==Types.LONGVARCHAR ||
			this.dataType==Types.NCHAR || this.dataType==Types.NVARCHAR || this.dataType==Types.LONGNVARCHAR)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public int getInt_value() {
		return int_value;
	}

	public Value setInt_value(int int_value) {
		this.int_value = int_value;
		this.double_value = int_value;
		if(this.dataType == 0){
			this.dataType = Types.INTEGER;
		}
		return this;
	}
	
	public boolean isIntValue() {
		if(this.dataType==Types.INTEGER ||  this.dataType==Types.SMALLINT)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public long getLong_value() {
		return long_value;
	}

	public Value setLong_value(long long_value) {
		this.long_value = long_value;
		if(this.dataType == 0){
			this.dataType = Types.BIGINT;
		}
		this.double_value = long_value;
		return this;
	}
	
	public boolean isLongValue() {
		if(this.dataType==Types.BIGINT)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public double getDouble_value() {
		return double_value;
	}

	public Value setDouble_value(double double_value) {
		this.double_value = double_value;
		if(this.dataType == 0){
			this.dataType = Types.DOUBLE;
		}
		this.int_value = (int) double_value;
		return this;
	}
	
	public boolean isDoubleValue() {
		if(this.dataType==Types.FLOAT || this.dataType==Types.DOUBLE || this.dataType==Types.NUMERIC)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public float getFloat_value() {
		return float_value;
	}

	public Value setFloat_value(float float_value) {
		this.float_value = float_value;
		this.double_value = float_value;
		this.int_value = (int) double_value;
		if(this.dataType == 0){
			this.dataType = Types.REAL;
		}
		return this;
	}
	
	public boolean isFloatValue() {
		if(this.dataType==Types.REAL)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public boolean getBoolean_value() {
		return boolean_value;
	}

	public Value setBoolean_value(boolean boolean_value) {
		this.boolean_value = boolean_value;
		if(this.dataType == 0){
			this.dataType = Types.BOOLEAN;
		}
		return this;
	}
	
	public boolean isBooleanValue() {
		if(this.dataType==Types.BIT || this.dataType==Types.BOOLEAN)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public BigDecimal getBigdecimal_value() {
		return bigdecimal_value;
	}

	public Value setBigdecimal_value(BigDecimal bigdecimal_value) {
		this.bigdecimal_value = bigdecimal_value;
		if(bigdecimal_value != null)
		{
			this.double_value = bigdecimal_value.doubleValue();
		}
		
		if(this.dataType == 0){
			this.dataType = Types.NUMERIC;
		}
		this.int_value = (int) double_value;
		return this;
	}
	
	public boolean isBigdecimalValue()
	{
		if(this.dataType==Types.NUMERIC || this.dataType==Types.DECIMAL)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public Blob getBlob_value() {
		return blob_value;
	}

	public Value setBlob_value(Blob blob_value) {
		this.blob_value = blob_value;
		if(this.dataType == 0){
			this.dataType = Types.BLOB;
		}
		return this;
	}
	
	public boolean isBlobValue() {
		if(this.dataType==Types.BLOB)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public byte getByte_value() {
		return byte_value;
	}

	public Value setByte_value(byte byte_value) {
		this.byte_value = byte_value;
		if(this.dataType == 0){
			this.dataType = Types.TINYINT;
		}
		return this;
	}
	
	public boolean isByteValue() {
		if(this.dataType==Types.TINYINT)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public byte[] getBytes_value() {
		return bytes_value;
	}

	public Value setBytes_value(byte[] bytes_value) {
		this.bytes_value = bytes_value;
		if(this.dataType == 0){
			this.dataType = Types.VARBINARY;
		}
		return this;
	}
	
	public boolean isBytesValue() {
		if(this.dataType==Types.BINARY || this.dataType==Types.VARBINARY || this.dataType==Types.LONGVARBINARY)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public Date getDate_value() {
		return date_value;
	}

	public Value setDate_value(Date date_value) {
		this.date_value = date_value;
		if(this.dataType == 0){
			this.dataType = Types.DATE;
		}
		return this;
	}
	
	public boolean isDateValue() {
		if(this.dataType==Types.DATE)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public Time getTime_value() {
		return time_value;
	}

	public Value setTime_value(Time time_value) {
		this.time_value = time_value;
		if(this.dataType == 0){
			this.dataType = Types.TIME;
		}
		return this;
	}
	
	public boolean isTimeValue() {
		if(this.dataType==Types.TIME || this.dataType==Types.TIMESTAMP)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	public Object getObject_value() {
		return object_value;
	}

	public Value setObject_value(Object object_value) {
		this.object_value = object_value;
		return this;
	}

	public Clob getClob_value() {
		return clob_value;
	}

	public Value setClob_value(Clob clob_value) {
		this.clob_value = clob_value;
		if(this.dataType == 0){
			this.dataType = Types.CLOB;
		}
		return this;
	}
	
	public boolean isClobValue() {
		if(this.dataType==Types.CLOB)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

}

import static org.junit.Assert.*;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Test;
import com.ojdbc.sql.ConnectionManager;
import com.ojdbc.sql.ConnectionObject;
import com.ojdbc.sql.DataBase;
import com.ojdbc.sql.DataBaseEnum;
import com.ojdbc.sql.DataBaseManager;
import com.ojdbc.sql.MixedBatchSQL;
import com.ojdbc.sql.PreparedParam;
import com.ojdbc.sql.SQLColumn;
import com.ojdbc.sql.SQLResultSet;
import com.ojdbc.sql.SQLRow;
import com.ojdbc.sql.Value;

        
        String sql2 = "create table testinfo(nid INTEGER PRIMARY KEY autoincrement,title TEXT,num INTEGER)";
        boolean f2 = sqlite.exeSQLCreate(sql2);
        assertTrue(f2);
        
        String sql3 = "insert into testinfo (title,num) values('insert1',1)";
        int id = sqlite.exeSQLInsert(sql3);
        System.out.println("id:"+id);
        
        String sql4 = "insert into testinfo (title,num) values(?,?)";
        PreparedParam preparedParam = new PreparedParam();
        Value value1 = new Value();
        value1.setString_value("insert2");
        preparedParam.addParam(1, value1);
        Value value2 = new Value();
        value2.setInt_value(2);
        preparedParam.addParam(2, value2);
        int id2 = sqlite.exePreparedSQLInsert(sql4,preparedParam);
        System.out.println("id:"+id2);
        
        String sql5 = "update testinfo set title='update1' where num=1";
        boolean f5 = sqlite.exeSQLUpdate(sql5);
        assertTrue(f5);
        
        String sql6 = "update testinfo set title=? where num=?";
        PreparedParam preparedParam2 = new PreparedParam();
        Value value3 = new Value();
        value3.setString_value("update2");
        preparedParam2.addParam(1, value3);
        Value value4 = new Value();
        value4.setInt_value(2);
        preparedParam2.addParam(2, value4);
        boolean f6 = sqlite.exePreparedSQLUpdate(sql6, preparedParam2);
        assertTrue(f6);
        
        String sql7 = "select * from testinfo where num=1";
        SQLResultSet r = sqlite.exeSQLSelect(sql7);
        int size = r.getRowNum();
        System.out.println("返回记录数: "+size);
        for(int i=0;i<size;i++)
        {
        	SQLRow row = r.getRow(i);
        	Value v = row.getValue("title");
        	String s = v.getString_value();
        	System.out.println(s);
        	assertEquals("update1",s);
        }
        
        String sql8 = "select * from testinfo where num=?";
        PreparedParam preparedParam3 = new PreparedParam();
        Value value5 = new Value();
        value5.setInt_value(2);
        preparedParam3.addParam(1, value5);
        SQLResultSet r2 = sqlite.exePreparedSQLSelect(sql8, preparedParam3);
        int size2 = r2.getRowNum();
        System.out.println("返回记录数: "+size2);
        for(int i=0;i<size2;i++)
        {
        	SQLRow row = r2.getRow(i);
        	Value v = row.getValue("title");
        	String s = v.getString_value();
        	System.out.println(s);
        	assertEquals("update2",s);
        }
        
        String sql9 = "delete from testinfo where num=1";
        boolean f9 = sqlite.exeSQLDelete(sql9);
        assertTrue(f9);
        
        String sql10 = "delete from testinfo where num=?";
        PreparedParam preparedParam4 = new PreparedParam();
        Value value6 = new Value();
        value6.setInt_value(2);
        preparedParam4.addParam(1, value6);
        boolean f10 = sqlite.exePreparedSQLDelete(sql10, preparedParam4);
        assertTrue(f10);
        
        Map<String, PreparedParam> psqls = new HashMap<String, PreparedParam>();
        String sql11 = "insert into testinfo (title,num) values('tinsert1',3)";
        String sql12 = "insert into testinfo (title,num) values(?,?)";
        PreparedParam preparedParam5 = new PreparedParam();
        Value value7 = new Value();
        value7.setString_value("tinsert2");
        preparedParam5.addParam(1, value7);
        Value value8 = new Value();
        value8.setInt_value(4);
        preparedParam5.addParam(2, value8);
        psqls.put(sql11, null);
        psqls.put(sql12, preparedParam5);
        boolean t = sqlite.exeTransactionPreparedSQL(psqls);
        assertTrue(t);
        
        MixedBatchSQL mixedBatchSQL = new MixedBatchSQL();
        //mixedBatchSQL.addStaticBatchSQL(sql3); sqlite not support
        List<PreparedParam> preparedParams = new ArrayList<PreparedParam>();
        preparedParams.add(preparedParam);
        mixedBatchSQL.setPreparedBatchSQL(sql4, preparedParams);
        //
        //sqlite.exePreparedBatchSQL(sql4, preparedParams);
        //sqlite.exeBatchSQL(sqls);
        //
        boolean fx = sqlite.exeMixedBatchSQL(mixedBatchSQL);
        assertTrue(fx);
	}
	
	@Test
	public void ConnectionObjectTest1() throws SQLException {
		
		DataBaseEnum type = DataBaseEnum.SQSLITE;
		String dataBaseURL = "jdbc:sqlite://E:/shaogaige/iNote/iNoteRun/data/iNoteData.note";
		String userName = "";
		String passWord = "";
		
		//***************************************************************************************
		//this operation will take a while,and make you get connection faster.
		//It should execute in system-initialization,but not necessary.
		//根据配置初始化，这个操作需要消耗一定的时间，建议放在系统初始化。执行此操作后，会加速第一次获取数据库连接的耗时。
		//ConnectionManager.initConnectionPoolByConfigure(type, dataBaseURL, userName, passWord);
		//***************************************************************************************
		

		ConnectionObject connobj = ConnectionManager.borrowConnectionObject(type, dataBaseURL, userName, passWord);
