利用Oracle自帶的連線池類的一例 (轉)
利用Oracle自帶的連線池類的一例 (轉)[@more@]/**
封裝了對的連線,用於處理語句。
@author:yancheng(sharetop studio)
@version:1.0.0
*/
package Util;
import .sql.*;
import java.io.*;
import javax.sql.*;
import javax.naming.*;
import ..pool.*;
public class OraPooledSQL
{
private PooledConnection dbpool;
/**
@param ConnectionURL 連線名 如: jdbc:odbc:myODBC
@param UserID 名
@param Pass 使用者密碼
*/
public OraPooledSQL(String ConnectionURL,String UserID,String PassWord)
{
try{
OracleConnectionPoolData ocpds = new OracleConnectionPoolDataSource();
ocpds.setURL(ConnectionURL);
ocpds.setUser(UserID);
ocpds.setPassword(PassWord);
dbpool = ocpds.getPooledConnection();
}
catch(Exception ex)
{
System.err.println("Error in PooledSQL-construct : ");
ex.printStackTrace(System.err);
}
}//end OraPooledSQL
//close dbpool
protected void finalize()
{
if( dbpool != null )
{
try
{
dbpool.close();
}
catch(Exception ex)
{
}
}
}
/**
用於、新增或刪除的SQL語句
@param SQL SQL語句字串,如:insert into tablename values(id,......)
*/
public int Update(String SQL)
{
Statement stmt = null;
int rc = 0;
Connection connection = null;
try
{
connection = dbpool.getConnection();
stmt = connection.createStatement();
rc = stmt.executeUpdate(SQL);
}
catch( Exception ex )
{
System.err.println("Error in Update - OraPooledSQL : ");
ex.printStackTrace(System.err);
}
return rc;
} //end Update()
/**
用於查詢的SQL語句
@param SQL SQL語句字串,如: * from tablename
*/
public ResultSet Query(String SQL)
{
Statement stmt = null;
ResultSet rs = null;
Connection connection = null;
try
{
connection = dbpool.getConnection();
stmt = connection.createStatement();
rs = stmt.executeQuery(SQL);
}
catch( Exception ex )
{
System.err.println("Error in Query - SQLBean : ");
ex.printStackTrace(System.err);
}
return rs;
} //end Query
} //end Class
封裝了對的連線,用於處理語句。
@author:yancheng(sharetop studio)
@version:1.0.0
*/
package Util;
import .sql.*;
import java.io.*;
import javax.sql.*;
import javax.naming.*;
import ..pool.*;
public class OraPooledSQL
{
private PooledConnection dbpool;
/**
@param ConnectionURL 連線名 如: jdbc:odbc:myODBC
@param UserID 名
@param Pass 使用者密碼
*/
public OraPooledSQL(String ConnectionURL,String UserID,String PassWord)
{
try{
OracleConnectionPoolData ocpds = new OracleConnectionPoolDataSource();
ocpds.setURL(ConnectionURL);
ocpds.setUser(UserID);
ocpds.setPassword(PassWord);
dbpool = ocpds.getPooledConnection();
}
catch(Exception ex)
{
System.err.println("Error in PooledSQL-construct : ");
ex.printStackTrace(System.err);
}
}//end OraPooledSQL
//close dbpool
protected void finalize()
{
if( dbpool != null )
{
try
{
dbpool.close();
}
catch(Exception ex)
{
}
}
}
/**
用於、新增或刪除的SQL語句
@param SQL SQL語句字串,如:insert into tablename values(id,......)
*/
public int Update(String SQL)
{
Statement stmt = null;
int rc = 0;
Connection connection = null;
try
{
connection = dbpool.getConnection();
stmt = connection.createStatement();
rc = stmt.executeUpdate(SQL);
}
catch( Exception ex )
{
System.err.println("Error in Update - OraPooledSQL : ");
ex.printStackTrace(System.err);
}
return rc;
} //end Update()
/**
用於查詢的SQL語句
@param SQL SQL語句字串,如: * from tablename
*/
public ResultSet Query(String SQL)
{
Statement stmt = null;
ResultSet rs = null;
Connection connection = null;
try
{
connection = dbpool.getConnection();
stmt = connection.createStatement();
rs = stmt.executeQuery(SQL);
}
catch( Exception ex )
{
System.err.println("Error in Query - SQLBean : ");
ex.printStackTrace(System.err);
}
return rs;
} //end Query
} //end Class
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-987878/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 利用weblogic的POOL(連線池)連線資料庫 (轉)Web資料庫
- python中自帶的線程式池Python線程
- Oracle 連線池配置Oracle
- oracle occi 連線池Oracle
- Java模擬.NET的連線池 (轉)Java
- druid資料庫連線池的配置類UI資料庫
- 自定義帶監控的資料庫連線池資料庫
- Jdbc 封裝, 利用反射, 加入連線池JDBC封裝反射
- 【Java】Spring和Tomcat自帶的連線池實現資料庫操作JavaSpringTomcat資料庫
- tomcat自帶連線池dbcp配置以及最佳化說明Tomcat
- cx_Oracle.SessionPool 連線池OracleSession
- 連線SQL SERVER的公共類 (轉)SQLServer
- 【JDBC】java連線池模擬測試 連線oracleJDBCJavaOracle
- 【JDBC】使用OracleDataSource建立連線池用於連線OracleJDBCOracle
- PG 資料庫連線池寫法優化一例資料庫優化
- 利用cygwin連線gnome或kde的桌面(轉)
- 帶你進入資料庫連線池資料庫
- golang開發:類庫篇(二) Redis連線池的使用GolangRedis
- 一個不錯的JDBC連線池教程(帶具體例子)JDBC
- 教你正確地利用Netty建立連線池Netty
- 連線池
- Tomcat 的 JDBC 連線池TomcatJDBC
- Proxool 連線池的配置使用
- 有關連線池的疑惑。
- HikariCP連線池的學習
- golang連線MySQL時候的連線池設定GolangMySql
- Oracle 連線條件中帶有OR的測試Oracle
- oracle資料庫連線後,hang機一例Oracle資料庫
- Tomcat4的資料庫連線池配置 (轉)Tomcat資料庫
- Oracle 表連線方式詳解(外連結、內連線、自連線)Oracle
- Go連線池Go
- HTTP連線池HTTP
- ServiceStack.Redis的原始碼分析(連線與連線池)Redis原始碼
- Swoole MySQL 連線池的實現MySql
- 資料庫連線池的理解資料庫
- 資料庫連線池的使用資料庫
- WASCE的資料庫連線池資料庫
- (請問)weblogic的連線池Web