관리 메뉴

moozi

oracle jdbc 연결방법 본문

TIS_2017/응용sw_2기

oracle jdbc 연결방법

moozi 2017. 7. 20. 14:11

Connection conn = null; // 연결객체

        ResultSet rs = null;    // select한 결과를 저장하는 객체

        Statement stmt = null;  // sql을 실행하기 위한 객체 

        String url = null;      // 서버 url

        String id = "hr";       // ID

        String pw = "1234";     // PW

        

        url ="jdbc:oracle:thin:@localhost:1521:orcl";

        try {

Class.forName("oracle.jdbc.driver.OracleDriver");// jdbc driver load

} catch (ClassNotFoundException e) {

e.printStackTrace();

}

        try {

conn = DriverManager.getConnection(url,id,pw);// 연결

} catch (SQLException e) {

e.printStackTrace();

}

        

        System.out.println("연결되었습니다.");

'TIS_2017 > 응용sw_2기' 카테고리의 다른 글

jdbc 연습문제01  (0) 2017.07.20
오라클 jdbc기초  (0) 2017.07.20
오라클연습문제07  (0) 2017.07.19
오라클연습문제06  (0) 2017.07.18
오라클연습문제5  (0) 2017.07.17
Comments