THINGS TO KNOW

Okay so far we learnt the steps to do with JDBC. Now lets see the important interface in JDBC

  • Connection interface
  • Statement interface
  • PreparedStatement interface
  • CallableStatement interface
  • ResultSet interface
These interfaces are actually implemented by the database vendors driver classes  and with the help of those classes we are able to use the methods present int them and connect to Database.Lets see what these interfaces are meant for

>>Connection helps in connecting to specific Database.

>>Statement used to create a statement(query) and then execute it.

>>PreparedStatement's purpose is same as statement but it is preferable over statement because it can avoid sql injection and unnecessary object creations.

>>CallableStatement used to execute stored procedures.

>>ResultSet stores the records obtained from Database and we can traverse among records with the help of methods in ResultSet.

ImportantMethods

>>executeUpdate() used to execute DML commands(insert,update,delete).
   It returns no.of rows affected.

>>executeQuery() used to execute select command and returns set of records.

>>execute() is used when you dont know which method to be used for executing SQL statements,This will return a boolean. TRUE indicates the result is a ResultSet and FALSE indicates it has the int value which denotes number of rows affected by the query.

No comments :

Post a Comment

Designed By Seo Blogger Templates