::: 강좌/소스/문서 :::

강좌/소스/문서 성격에 맞지 않는 광고,비방,질문의 글은 즉시 삭제하며
내용을 복사하여 사용할 경우 반드시 이곳(http://www.howto.pe.kr)을 출처로 명시하여 주세요


Category

  신훈재(2004-06-18 14:08:58, Hit : 5855, Vote : 1512
 [자바] 시스템 프로퍼티를 이용한 드라이버 로드

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

public class JDBCProperties {
        
        public static void main(String args[]) {
                Properties pt = new Properties();
                pt.put("jdbc.drivers","oracle.jdbc.driver.OracleDriver");
                System.setProperties(pt);

                try {
            
                        System.out.println("Connection...");
                        Connection conn =
                                DriverManager.getConnection ("jdbc:oracle:thin:@127.0.0.1:1521:specular",
                                           "scott", "tiger");
        
                        System.out.println("Creating a Statement...");
                        // Create a Statement
                        Statement stmt = conn.createStatement ();

                        // Select the ENAME column from the EMP table
                        ResultSet rset = stmt.executeQuery ("select ENAME from EMP");

                        // Iterate through the result and print the employee names
                        while (rset.next ())
                                System.out.println (rset.getString (1));
                
                        stmt.close();
                        conn.close();
                } catch(SQLException e){
                        e.printStackTrace();
                        System.out.println(e.getErrorCode());
                        System.out.println(e.getMessage());
                }
        }
};







  [Java/PHP] [자바] 시스템 프로퍼티를 이용한 드라이버 로드  신훈재 2004/06/18 5855 1512
2   [Java/PHP] [자바] JDBC-ODBC 연결 예제  신훈재 2004/06/18 10488 1779
1   [Java/PHP] [자바] DB 컨넥션 풀  신훈재 2004/06/18 10409 1974

[1][2][3][4][5][6][7][8][9] 10
 

Copyright 1999-2020 Zeroboard / skin by zero