Overview
of Interfaces and Classes used in this example
The java.lang.Class
class
Objects of this class represent classes and interfaces in a running
Java application. Class objects are constructed automatically by the
Java Virtual Machine as classes are loaded.
Methods
- public static Class forName(String
className) - This method is used for loading classes. It returns
the Class object associated with the class or interface with the given
string name.
The java.sql.DriverManager
Class
This class maintains a list of registered Driver
classes.
Methods
- public static Connection
getConnection(String url) - This method can be used
to establish a connection to the given database URL. The DriverManager
selects an appropriate driver from the set of registered JDBC drivers.
The
java.sql.Connection Interface
A Connection object represents a connection
with the database. An application can have one or more connections with
a database.
Methods
- public Statement createStatement()
- It creates a Statement object for sending SQL statements to the
database.
The java.sql.Statement
Interface
The Statement object is used to send
SQL statements to a database.
Methods
- public ResultSet executeQuery(String
sql) - It executes an SQL statement that returns a single
ResultSet
object.
- public int executeUpdate(String
sql) - It executes an SQL
INSERT, UPDATE or DELETE statement.
The java.sql.ResultSet
Interface
A ResultSet object contains the results
of executing an SQL query.
Methods
- public boolean next() - It moves the cursor to the next row.
A ResultSet cursor
is initially positioned before the first row; the first call to the
next() method makes
the first row the current row.
|