What is Statement and prepared statement in SQL
Statement and prepared statement are the interfaces declared in JAVA.SQL.
While you connecting to a database these are required.
If you use statement interface you must give input values to be inserted in the program itself. We can't change change the values after compilation. To create a statement: Statement stmt = conn.createStatement();
In case of PreparedStatement only we have to generate a query inside the program. This query will be compiled when the program is being compiled. And the input for the values will be inserted at runtime using setXXX(); method . This method has two arguements. they are first one: Arguement sequence number, secon one : corresponding for its argument.
To create a preparedstatement PreparedStatement ps = conn.prepareStatement( "SELECT i., j. FROM Omega i, Zappa j" + "WHERE i = ? AND j = ?" );
Examples: Data type Corresponding methods ---------- -------------------- CHAR setString() VARCHAR2 setString() NUMBER setBigDecimal() setBoolean() setByte() setShort() setInt() setLong() setFloat() setDouble()
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.