JDBC (the Java Database Connection) is the standard method of accessing databases from Java. Sun developed the JDBC library after considering Microsoft's ODBC. Their aims were to get something similar but easier to learn and use: ODBC is complex because it has a few very complex calls. JDBC has split up this complexity into many more calls, but with each of them being relatively simple.
Accessing a database using JDBC involves a number of steps:
While the above is the standard pattern, there are variations: Instead of a Statement, you can get a PreparedStatement (which allows a query to be pre-compiled for extra performance when executed repetitively). An update query may only return a count of the number of rows updated, inserted or deleted instead of a ResultSet. There are calls to get information about the database and about ResultSet objects (e.g. the number, names and types of columns). There are calls to support transactional updates to the database.
Accessing a database using JDBC involves a number of steps:
- Get a Connection object connected to a database
- Get a Statement object from an open Connection object
- Get a ResultSet from a Statement's query execution
- Process the rows from the ResultSet
No comments:
Post a Comment