package cc.apps.report;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import com.order.cc.sys.dao.FoJdbcDaoSupport;
public class connectData extends FoJdbcDaoSupport{
/* 连接Oracle */
String strIVRUrl = "jdbc:oracle:thin:@127.0.0.1:1521:ccdb";
String strIVRUser = "";
String strIVRPASS = "";
/* 连接DB2 */
String strCTIUrl = "jdbc:db2://**:6789/CTIDB";
String strCTIUser = "";
String strCTIPASS = "";
/* 连接Access */
String strAccUrl = "jdbc:odbc:220acc97";
String strAccUser = "";
String strAccPASS = "";
/* 连接Sql Server */
String strSqlUrl = "jdbc:sqlserver://**:1433;DatabaseName=**";
String strSqlUser = "**";
String strSqlPASS = "**";
Connection connI = null;
Connection connC = null;
Connection connA = null;
public Connection connectIVR() throws SQLException {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
connI = DriverManager.getConnection(strIVRUrl, strIVRUser, strIVRPASS);
}
catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
}
return connI;
}
public Connection connectCTI() throws SQLException {
try {
Class.forName("COM.ibm.db2.jdbc.net.DB2Driver");
connC = DriverManager.getConnection(strCTIUrl, strCTIUser, strCTIPASS);
}
catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
}
return connC;
}
public Connection connectACC() throws SQLException {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
connA = DriverManager.getConnection(strAccUrl, strAccUser, strAccPASS);
}
catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
}
return connA;
}
public Connection connectSQL() throws SQLException {
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
connA = DriverManager.getConnection(strSqlUrl, strSqlUser, strSqlPASS);
}
catch (Exception e) {
e.printStackTrace();
logger.error(e.getMessage());
}
return connA;
}
}
-------------------------调用方法-------------------------------------
public class ReportDAO extends connectData implements IReportDAO {
public ResultEntity queryComCheackCountRes(String year, String month, String monthEnd, String groupName) {
ResultEntity res = new ResultEntity();
List dateList = new ArrayList();
Connection conn = null;
ResultSet rs = null;
Statement stmt = null;
try {
conn = connectSQL();
conn = this.getConnection();
stmt = conn.createStatement();
String sql = getSql(year, month, monthEnd, groupName);
rs = stmt.executeQuery(sql);
Map avgMap = new HashMap<String, Double>();
while (rs.next()) {
getRsDateList(dateList, rs, avgMap);
}
res.setList(dateList);
res.setAvgMap(avgMap);
} catch (SQLException sqle) {
sqle.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
if (rs != null)
rs.close();
if (stmt != null)
stmt.close();
if (conn != null)
conn.close();
} catch (SQLException sqe) {
sqe.printStackTrace();
}
}
return res;
}