관리 메뉴

moozi

oracle jdbc select기초 본문

TIS_2020/빅데이터2020_1기

oracle jdbc select기초

moozi 2020. 9. 29. 16:55
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBC01 {

	public static void main(String[] args) {
		try {
			//oracle jdbc드라이버 로드
			Class.forName("oracle.jdbc.driver.OracleDriver");// jdbc driver load
			//Connection
			Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:myoracle","ora_user","hong");// 연결
			System.out.println("연결완료");
			
			//Statement객체 생성
			Statement stmt=conn.createStatement();
			ResultSet rs=stmt.executeQuery("select * from student2");
			while(rs.next()) {
				System.out.println(rs.getString("id"));
				System.out.println(rs.getString("name"));
				System.out.println(rs.getString("dept"));
			}
			rs.close();
			stmt.close();
			conn.close();
			
		}catch(Exception e) {
			e.printStackTrace();
		}

	}

}

'TIS_2020 > 빅데이터2020_1기' 카테고리의 다른 글

10/05 haksa  (0) 2020.10.05
10/05 oracle jdbc 기초  (0) 2020.10.05
oracle jdbc select기초  (0) 2020.09.29
oracle jdbc연결테스트  (0) 2020.09.29
오라클연습문제풀이  (0) 2020.09.29
sql join 문법  (0) 2020.09.23
0 Comments
댓글쓰기 폼