글쓴이 :김영선 2000년 6월 18일 14:08:58
In Reply to: JDBC관련 오라클 에러... posted by 김매경 on 2000년 6월 08일 09:58:52:
다음 코드로 한번 초기화 시켜보세요..
----> new Database();
//소스
import java.util.*;
import java.sql.*;
public class Database{
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
public Database(String serverName){
//String serverName = "203.237.102.167";//서버의 이름을 입력 ip or 호스트이름
String DB_URL = ("jdbc:oracle:thin:@"+serverName+":1521:ORCL");//프로토콜이름
String ID = "scott";
String PASS = "tiger";
//driver loading
try{
Class.forName("oracle.jdbc.driver.OracleDriver");//드라이브찾기
}catch(ClassNotFoundException e){
e.printStackTrace();
}
//db connect
try{
conn = DriverManager.getConnection(DB_URL,ID,PASS);//커넥션하는부분
stmt = conn.createStatement();//객체를 생성하는 부분
//session connect //세션을 연결하는 부분
}catch(SQLException e){
e.printStackTrace();
}
}
//Close the connection with the database server
//데이타베이스와의 연결을 해제throws SQLException
public void close() {
try {
conn.close();
}catch(SQLException e){
System.out.println("Disconnection error");
}
}
}