import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
public class Main {
public static void main(String[] argv) throws Exception {
Date date = new Date(0);
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbctutorial",
"root", "root");
PreparedStatement prest = con.prepareStatement("INSERT Records VALUES(?,?,?)");
prest.setInt(1, 1);
prest.setString(2, "R");
prest.setDate(3, date.valueOf("1998-1-17"));
int row = prest.executeUpdate();
}
}
|