Introduction    Java Database Connection (JDBC) API allows the Java programmers to access different relational and NoSQL databases like Oracle, MySQL, SQL Server, etc. It helps to store, access and manipulate the data stored in these databases.   In this post, we will explore how to set the NULL values in PreparedStatement.    Null String data type   For String data type, it does not matter if the value to be set as a parameter in the SQL query is NULL.       Other data types like Integer, Float, Double, Date, etc.   For data types like Integer , Float , Double , Date we have to explicitly call the setNull method.     Example     String name = null ;   Long id = null ;        PreparedStatement ps = connection.prepareStatement("select * from person where first_name = ? and id = ?");      ps.setString(1,name);     The above line will execute without throwing any exception     ps.setLong(2, id);     In the above line of code, since id is null, it will throw java.lang.Nul...
Blog about programming