Preparestatament is more secure and effective in preventing SQL injection, preparestatament is more efficient for statements that are repeatedly executed more efficiently when executing a variable parameter of SQL, PreparedStatement is more efficient than statement , because it is certainly more efficient for a DBMS to precompile a SQL than to compile one SQL multiple times preparestatament can use variables in SQL statements, for example: statament stmt = conn. Preparestatement ("Select * from tabs where id=?") and tab_name=? ") To Assignment, the first parameter represents? Location The second parameter represents to that? The value passed is Stmt.setint (1, 1); Stmt.setstring ("Test", "TEST_JDBC"); Preparestament executes the DDL statement to use the Execute () method, which returns a Boolean value. True if execution of DDL succeeds otherwise false
The difference between JDBC Createstatament and preparestatament