Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class Main {
    public static void main(String[] argv) throws Exception {

        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbctutorial", "root", "root");

        String sql = "DELETE FROM product where year_made = ?";
        PreparedStatement prest = con.prepareStatement(sql);
        prest.setInt(1, 2008);
        int del = prest.executeUpdate();
        System.out.println("Number of deleted records: " + del);
        con.close();
    }
}