How to send SQL statements to databases for execution?

Describe with an example how to send SQL statements to databases for execution.

The following illustrates with examples, to send SQL statements to databases for execution:

- The SQL statements are to be created as objects. These objects are to be assigned to Statement reference.
Example:
Statement stmts = con.createStatement();//creates a statement object

- The specific SQL statements are to be executed and the result should be captured
Example:
ResultSet rsltSet = stmts.executeQuery(“select * from emp”);

- To make a row inserted into the database and committed:
stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery("select * from emp");
   rs.moveToInsertRow();
   rs.updateInt(1,15); // first attribute with value 15
   rs.updateString(2,"Vismay”); // second value with Vismay
   rs.updateFloat(3,4500); // third attribute with 4500
   rs.insertRow();
con.commit();
What is a “dirty read”?
What is a “dirty read”? - In typical database transactions, one transaction reads changes the value while the other reads the value before committing or rolling back by the first transaction...
Cold backup, hot backup, and warm backup recovery
JDBC - Cold backup, hot backup, and warm backup recovery - Cold backup is a recovery technique, in which the files must be backed up before the database is restarted at the same time...
What is 2 phase commit?
What is 2 phase commit? - Distributed transactions are performed by relational databases...
Post your comment