Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
OracleTools.java
Package: (J2EE)oa.rar [view]
Upload User: lm2018
Upload Date: 2015-12-12
Package Size: 30449k
Code Size: 1k
Category:
Jsp/Servlet
Development Platform:
Java
- package com.oa.util;
- import java.sql.Connection;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.sql.Statement;
- import javax.naming.Context;
- import javax.naming.InitialContext;
- import javax.naming.NamingException;
- import javax.sql.DataSource;
- public class OracleTools {
- /**
- * 从连接池里获取一个链接
- * @author student
- *
- */
- public static Connection getConn(){
- Connection conn = null;
- try {
- Context context = new InitialContext();
- DataSource ds = (DataSource)context.lookup("java:comp/env/jdbc/oracle");
- conn = ds.getConnection();
- } catch (NamingException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- } catch (SQLException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- } finally{
- return conn;
- }
- }
- /**
- * 关闭数据库连接
- * @param rs
- * @param st
- * @param conn
- */
- public static void closeConn(ResultSet rs, Statement st, Connection conn){
- try {
- if(rs!=null){
- rs.close();
- rs = null;
- }
- if(st!=null){
- st.close();
- st = null;
- }
- if(conn!=null){
- conn.close();
- conn = null;
- }
- } catch (SQLException e) {
- // TODO 自动生成 catch 块
- e.printStackTrace();
- }
- }
- }