java 读写EXCEL文件的源码
源代码在线查看: dbconnection.java
/********************************************************************
*
* $RCSfile: DBConnection.java,v $ $Revision: 1.1 $ $Date: 2003/09/22 08:06:24 $
*
* $Log: DBConnection.java,v $
* Revision 1.1 2003/09/22 08:06:24 icestone
* init
*
*
*
**********************************************************************/
package pcdmupgradedata;
/**
* Title: 数据库连接类
* Description:
* Copyright: Copyright (c) 2003/05/23
* Company:
* @author Peter
* @version 1.0
*/
import java.sql.*;
public class DBConnection {
private String strIP = null; //数据库IP地址
private String strSID = null; //SID
private String strUser = null; //用户名
private String strPassword = null; //密码
public DBConnection() {
}
public void setConnectString(String strIP,String strSID,String strUser,String strPassword){
this.strIP = strIP;
this.strSID = strSID;
this.strUser = strUser;
this.strPassword = strPassword;
}
public Connection getConnection(){
//获取数据库连接对象
Connection conn = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException e) {
System.out.println("Can't find class oracle.jdbc.driver.OracleDriver");
System.exit(1);
}
try {
conn = DriverManager.getConnection(
"jdbc:oracle:thin:@" + strIP + ":1521:" + strSID,strUser,strPassword);
}
catch(SQLException e) {
System.out.println("SQL error: " + e.toString());
}
return conn;
}
public void closeConnection(Connection conn){
//关闭数据库连接
if (conn != null)
try {conn.close();} catch(SQLException ignore) {}
}
}