package jdbc0327;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class Test02_insert {
public static void main(String[] args) {
try {
String url="jdbc:oracle:thin:@localhost:1521:xe";
String user="system";
String password="1234";
String driver ="oracle.jdbc.driver.OracleDriver";
Class.forName(driver);
Connection con=DriverManager.getConnection(url, user, password);
System.out.println("오라클 DB연결 성공");
StringBuilder sql= new StringBuilder();
sql.append(" insert into sungjuk(sno, uname, kor, eng, mat, addr, wdate)");
sql.append(" values(sungjuk_seq.nextval,'손흥민',99,98,97,'Seoul',sysdate)");
PreparedStatement pstmt= con.prepareStatement(sql.toString());
int cnt=pstmt.executeUpdate();
System.out.println("실행결과"+cnt);
} catch (Exception e) {
System.out.println("오라클 DB연결 실패"+ e);
}
}
}