import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.Time;
public class Main {
public static void main(String[] argv) throws Exception {
Time time = new Time(0);
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbctutorial",
"root", "root");
String sql = "INSERT child VALUES(?,?)";
PreparedStatement prest = con.prepareStatement(sql);
prest.setString(1, "vinod");
prest.setTime(2, time.valueOf("1:60:60"));
int row = prest.executeUpdate();
System.out.println(row + " row(s) affectec)");
}
}
|