Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package belajar.jdbc;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.SQLException;
- public class MainApplication {
- public static void main(String[] args) {
- try {
- Connection koneksi = DriverManager
- .getConnection("jdbc:mysql://localhost:3306/jdbc_mysql", "root", "admin");
- String sql = "DELETE FROM mahasiswa WHERE nim = ?";
- PreparedStatement ps = koneksi.prepareStatement(sql);
- System.out.println("sebelum set value: " + ps.toString());
- ps.setString(1, "10511150");
- System.out.println("setelah set value: " + ps.toString());
- ps.executeUpdate();
- ps.close();
- koneksi.close();
- } catch (SQLException ex) {
- System.err.println("Database tidak ditemukan!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement