Skip to main content

Posts

Showing posts from January, 2014

Prepared Statements for Database driven application

Prepared Statement is commonly used by application to execute the same parameterized SQL statement again and again. Prepared statements are compiled only once. If we need to execute a statement multiple times then execution of prepared statement is faster as it is compiled only once, while in case if we are using direct statements then each statement is first compiled every time before execution. So, time taken in Prepared execution is lesser as compared to the time taken in direct execution. Prepared statement are also known as parameterized queries. Parameterized queries and prepared statements are features of database management systems that basically act as templates in which SQL can be executed. Example of Prepared Statement using Java and C# We are using Emp table. Here "id" is the primary key of the table. Following query will retrive all the data of a row for id =1 SELECT * FROM Emp WHERE id =1 Now, if we create a template of above statement and use that fo