If you want to execute a statement many time , "PreparedStatement " reduces execution time. Unlike a "Statement" object ,it is given an 'Sql' statement when it is created.This SQL statement is sent to the DBMS right away, where it is compiled. This means that when the PreparedStatement is executed, the DBMS can just run the PreparedStatement SQL statement without having to compile it first.
The advantage of using "PreparedStatement " is that you can use the same statement and supply it with different values each time you execute it.
Insertprepared.java
|
OUTPUT
| C:\Program
Files\Java\jdk1.6.0_18\bin>java Insertprepared Roll No Name Date of Birth 2147483647 Ankit 1985-06-06 2147483648 Somesh 1984-05-05 2147483649 Rajiv 1985-06-06 2147483649 Rahul 1985-06-06 |