package ex1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Program {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
String url = "jdbc:oracle:thin:@localhost:1521/xe";
String sql = "SELECT * FROM NOTICE";
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(url,"scott","tiger");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(sql);
if(rs.next()) {
String title = rs.getString("TITLE");
System.out.println(title);
st.close();
con.close();
}
}
}
package ex1;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Program {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
String url = "jdbc:oracle:thin:@localhost:1521/xe";
String sql = "SELECT * FROM NOTICE";
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(url,"scott","tiger");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery(sql);
if(rs.next()) {
String title = rs.getString("TITLE");
System.out.println(title);
st.close();
con.close();
}
}
}
'JAVA Programming > JDBC' 카테고리의 다른 글
[8] JDBC 트랜잭션 처리 (0) | 2020.08.05 |
---|---|
[6] JDBC DB테이블에 값을 넣어서 레코드의 모든 컬럼값 불러오기 (0) | 2020.08.04 |
[3] JDBC 기본 코드의 이해 (0) | 2020.08.04 |
[2] DBMS 와 JDBC Driver 준비하기 (0) | 2020.08.04 |
[1] DB Client , DB API , JDBC 와 JDBC Driver , JDBC 이용절차 (0) | 2020.08.04 |