728x90
JDBC드라이버를 로드하고 연결하는 기본설정 폼
//JDBC 기본프로그래밍
//1. 드라이버를 찾아서 객체발생
//2. Connection 객체를 생성
//3. 작업객체(정적객체/동적객체):Statement/PreparedStatement or CallableStatement
public class Ex06 {
public static void main (String[] args) {
//특정한 클래스를 찾아내는 클래스가 있는데 ... 이것을 이용하여
//오리클 드라이버를 찾아낸다
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("오라클 드라이버 검색 성공!");
}catch(ClassNotFoundException e) {
System.out.println("검색실패!!");
}
Connection conn = null;
try {
String user ="scott";
String pw="1234";
String url = "jdbc:oracle:thin:@localhost:1521:BTDB";
conn = DriverManager.getConnection(url, user, pw);
System.out.println("Oracle과 연결됨.");
} catch (SQLException e) {
System.out.println("error=연결객체만들기 오류="+e);
}
}
}
728x90
'국비교육과정 > JAVA' 카테고리의 다른 글
[JDBC] MariaDB-연결-Java (0) | 2022.03.17 |
---|---|
★JFrame활용 코드 (0) | 2022.03.17 |
★JDBCConnection 코드 (0) | 2022.03.17 |
9일차 (0) | 2022.03.17 |
★Lamda 중요코드 (0) | 2022.03.16 |
댓글