-
토이 프로젝트1 - 책 예약 프로그램_3프로그래밍/JAVA 2024. 5. 29. 15:38728x90반응형SMALL
예약 대상이 되는 책 등록하는 부분
import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; public class BookInfo { public void BookinfoRegist(String s, int n) { Connection conn = null; try { Class.forName("oracle.jdbc.OracleDriver"); conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.219.107:1521/xe","system","1234"); String sql = "" + "INSERT INTO bookinfo (bookid,bookno,userid)" + "VALUES (?,?,?)"; PreparedStatement pstmt = conn.prepareStatement(sql); pstmt.setString(1, s); pstmt.setInt(2, n); pstmt.setString(3, "def"); int row = pstmt.executeUpdate(); pstmt.close(); }catch (ClassNotFoundException e) { e.printStackTrace(); }catch (SQLException e) { e.printStackTrace(); }finally { if(conn != null) { try { conn.close(); }catch(SQLException e) {} } } } }
728x90반응형LIST'프로그래밍 > JAVA' 카테고리의 다른 글
JAVA 코딩테스트 문제 9 - 가위바위보 (1) 2024.06.16 java 코딩테스트 문제 8 (0) 2024.06.01 토이 프로젝트1 - 책 예약 프로그램_2 (0) 2024.05.28 토이 프로젝트1 - 책 예약 프로그램_1 (0) 2024.05.27 프로그래밍 공부법 (0) 2024.04.28