-
Notifications
You must be signed in to change notification settings - Fork 0
5 JDBC
plor10 edited this page Nov 15, 2018
·
3 revisions
197 DISTRIBUTED JAVA JDBC Code Database Connections ̈ Import JDBC Packages: Add import statements to your Java program to import required classes in your Java code. ̈ Database URL Formulation: This is to create a properly formatted address that points to the database to which you wish to connect. ̈ Create Connection Object: Finally, code a call to the DriverManager object's getConnection ( ) method to establish actual database connection. 9 JDBC Code Statement Object ̈ boolean execute (String SQL): Returns a boolean value of true if a ResultSet object can be retrieved; otherwise, it returns false. Use this method to execute SQL DDL statements or when you need to use truly dynamic SQL. ̈ int executeUpdate (String SQL): Returns the number of rows affected by the execution of the SQL statement. Use this method to execute SQL statements for which you expect to get a number of rows affected
for example, an INSERT, UPDATE, or DELETE statement. ̈ ResultSet executeQuery (String SQL): Returns a ResultSet object. Use this method when you expect to get a result set, as you would with a SELECT statement. 10