JDBC PPT(1)(1)
JDBC PPT(1)(1)
JAVA DATABASE
CONNECTIVITY
INTRODUCTION TO JDBC
DB1
DB2
STEPS TO CONNECT
2.Establish Connection
3.Create Statement
4.Execute Statement
5.Close
JDBC
CONCEPTUAL COMPONENTS
2.Checks with each driver to determine if it can handle the specified URL
• Constructor is private
JDBC
DRIVERS
Used for CREATE, ALTER, DROP Used for the queries which are to be
statements. executed multiple times.
Performance is very low. Performance is better than Statement.
Used to execute normal SQL queries. Used to execute dynamic SQL queries.
This interface cannot be used for This interface can be used for retrieving
retrieving data from database. data from database.
JDBC
METHODS TO EXECUTE STATEMENT
There are 3 Methods to execute statement
execute():
• This method is used for all the commands like DDL,DML,DQL.
• Return type of execute method is Boolean.
• Return true when DQL commands are used.
• Return false when other than DQL commands are used.
executeUpdate():
• This method is used for DML commands
• Return type is int.
• DML commands like update,insert,delete.
executeQuery():
• This method is used for DQL commands
• Return type is Resultset.
• This method is used for Select query.
JDBC
RESULTSET