목록JDBC (4)
Gentle Breeze
package com.sds.jdbc.board; import java.sql.*; public class SearchBoardList { private Connection conn; private Statement stmt; private ResultSet rs; private String driver = "oracle.jdbc.driver.OracleDriver"; private String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE"; private String id = "hr"; private String pass = "hr"; private String sql = " select * from board "; public void getBoardList(){ tr..
- JDBC를 이용한 DB 연결 * 1단계 - import java.sql.*; * 2단계 - 드라이버를 load * 3단계 - Connection 객체를 생성 * 4단계 - Statement 객체를 생성 및 질의 수행 * 5단계 - SQL 문에 결과물이 있다면 ResultSet 객체를 생성 * 6단계 - 모든 객체를 닫음
import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class JDBCTest { public static void main(String[] args) throws Exception { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection connection = DriverManager.getConnection( "jdbc:oracle:thin:@127.0.0.1:8088:XE", "hr", "hr"); Statement statement = connection.createStatement..