목록JAVA/chapter27_preparestatement (5)
WON.dev
package org.joonzis.ex; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import org.joonzis.db.DBConnection; public class Ex04_select { public static void main(String[] args) { Connection conn = null; PreparedStatement ps = null; ResultSet rs = null; try { conn = DBConnection.getConnection(); ps = (PreparedStatement) conn.createStatement(); String sql = "..
package org.joonzis.ex; import java.sql.Connection; import java.sql.PreparedStatement; import org.joonzis.db.DBConnection; public class Ex03_delete { public static void main(String[] args) { // 김씨 데이터 삭제 Connection conn = null; PreparedStatement ps = null; try { conn = DBConnection.getConnection(); String sql = "delete from person where name = '김씨'"; ps = conn.prepareStatement(sql); int result =..
package org.joonzis.ex; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.Statement; import org.joonzis.db.DBConnection; public class Ex02_update { public static void main(String[] args) { Connection conn = null; PreparedStatement ps = null; // sql의 값을 변수 처리 할 수 있다. try { conn = DBConnection.getConnection(); String sql = "UPDATE PERSON SET AGE=?,region=? where name=?..
package org.joonzis.ex; import java.sql.Connection; import java.sql.PreparedStatement; import org.joonzis.db.DBConnection; public class Ex01_insert { public static void main(String[] args) { Connection conn = null; PreparedStatement ps = null; // sql의 값을 변수 처리 할 수 있다. try { conn = DBConnection.getConnection(); String sql = "insert into person(name, age, region) values(?, ?, ?)"; // 나중에 setter로 채..
package org.joonzis.db; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; public class DBConnection { public static Connection getConnection() throws ClassNotFoundException, SQLException{ Class.forName("oracle.jdbc.driver.OracleDriver");// 외우자 String user = "scott"; String password = "tiger"; String url = "jdbc:oracle:thin:@localhost:1521:xe";// 외우자 Connect..