/***********************************************************************
//
//	파일명 : DBConnection
//	기능 : DB 연결 및 Statement 객체 생성
//	작성일 : 
//
************************************************************************/

package extractor.SCA_API;


import java.io.*;
import java.sql.*;
import java.util.*;

public class DBConnection {

	String driverName = "oracle.jdbc.driver.OracleDriver";
	String url = "jdbc:oracle:thin:@localhost:1521:etri";
	Connection con = null;
    Statement st = null;
	static int count = 0;
	
	public DBConnection() {
		try {
			Class.forName(driverName);
		} catch (ClassNotFoundException e) {
			System.out.println(e.getMessage());
		}
		
		try {
			con = DriverManager.getConnection(url, "scott", "tiger");
		}catch(SQLException e) {
			System.out.println(e.getMessage() + "Error : Connecting DB...");
			e.printStackTrace();
		}
		count++;
		System.out.println("called count = " + count);
		System.out.println("Connected DB...");
	}

	public void close() {
		try{
			con.close();
		}catch(Exception e) {
			System.out.println(e.getMessage());
		}
	}

	public Connection getConnection(){
		return con;
	}
	public Statement createStatement(){
		try{
			st = con.createStatement();
		}catch(Exception e){
			System.out.println(e.getMessage() + "Error : Make Statement Object...");
		}
		return st;
	}
}