JAVA对DB2数据库的详细操作·! JAVA对DB2数据库的详细操作·!

源代码在线查看: dbconnection.java

软件大小: 1497 K
上传用户: my
关键词: JAVA DB2 数据库 操作
下载地址: 免注册下载 普通下载 VIP

相关代码

				/**
				 * Copyright: Copyright (c) 2005-2008
				 * Company: TopSoft( http://www.topnet.net.cn)
				 * $Id: DBConnection.java,v 1.1 2007/04/03 03:40:26 wangpeng Exp $
				 */
				package com.topsoft.updateForYear;
				
				import java.sql.Connection;
				import java.sql.DriverManager;
				import java.sql.ResultSet;
				import java.sql.Statement;
				
				/**
				 * 数据库连接管理
				 */
				public class DBConnection {
				    public static Connection getCSVConnection(String path) {
				        try {
				            Class.forName("org.relique.jdbc.csv.CsvDriver");
				            return DriverManager.getConnection("jdbc:relique:csv:" + path);
				        } catch (Exception ex) {
				            throw new RuntimeException("错误:加载CSV驱动程序失败." + ex.getMessage());
				        }
				    }
				
				    public static void closeConnection(ResultSet rs, Statement stmt, Connection conn) {
				        try {
				            rs.close();
				            stmt.close();
				            conn.close();
				        } catch (Exception ex) {
				            throw new RuntimeException("错误:关闭连接失败." + ex.getMessage());
				        }
				    }
				
				    public static Connection getDB2Connection(){
				        try {
				            Class.forName("com.ibm.db2.jcc.DB2Driver");
				            return DriverManager.getConnection(ConfigProperties.getDB2URL().trim(),ConfigProperties.getDB2User().trim(), ConfigProperties.getDB2Pwd().trim());
				        } catch (Exception ex) {
				            throw new RuntimeException("错误:加载DB2驱动程序失败." + ex.getMessage());
				        }
				    }
				    	
				    
				}
							

相关资源