The java.sql package contain a Prepared Statement derived from the Statement interface. The Prepared Statement provides you to pass the parameter at runtime to the SQL statement, which is used for modify the data in a table.
In this Tutorial we want to describe you a code that help in understanding JDBC Insert Null. The program include a class JDBC Insert Null, Inside the class we have a main method that follows the list of steps -
Loading a driver by calling a class.forName( ),that accept driver class as argument. The DriverManager.getConnection ( )return you a connection object, provides a connection between url and database.
prepareStatement ( ):This return you a Prepared Statement object, perform an insertion of rows into employees table by passing data of Employee at runtime. The setString ( ) method set the value into the column of Employee table. The INSERT statement is executed using executeUpdate ( ),return you the numbers of rows modified and affected.
executeQuery ( ) - This method returns you a record set retrieved from a table in the database. The select statement is used to retain the records from the result set.
next ( ) - This method is used to retain next elements in a series.
Finally the print print the No, Name from a employee table present in database. In case there exist an exception in try block, the subsequent catch block catch and handle the exception.
No Name Girish Tewari Rohini Indian Komal Singh Rohini Indian Sandeep kumar Rohini Indian Amit Singh Rohini Indian Girish Tewari Rohini Indian Darshan Tewari Rohini Indian Rakesh Kanwal Delhi null
Recommend the tutorial