Class JdbcExamples
java.lang.Object
net.jrodolfo.java_evolution.java01.jdbc.JdbcExamples
Demonstrates the JDBC 1.1 driver-dispatch model introduced in Java 1.1.
Modern JDKs have expanded the original JDBC interfaces with many later methods. Rather than introduce later APIs or a dynamic-proxy compatibility layer into this Java 1.1 example, this class uses small local types that model the original roles: a driver manager selects a driver by URL, and the selected driver creates a connection.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classMinimal connection that exposes the selected URL and metadata.static final classMinimal metadata returned by the learning connection.static final classMinimal driver contract used by the learning model.static final classSmall model of the JDBC driver-selection role. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves a previously registered learning driver.openConnection(String jdbcUrl) Opens a connection through the small driver-manager model.intregisterLearningDriver(String urlPrefix) Registers a driver that accepts URLs beginning with the supplied prefix.
-
Constructor Details
-
JdbcExamples
public JdbcExamples()
-
-
Method Details
-
registerLearningDriver
Registers a driver that accepts URLs beginning with the supplied prefix. -
deregisterDriver
Removes a previously registered learning driver. -
openConnection
Opens a connection through the small driver-manager model.- Parameters:
jdbcUrl- URL requested by the application- Returns:
- connection created by the matching driver
- Throws:
SQLException- when no registered driver accepts the URL
-
registeredLearningDriverCount
public int registeredLearningDriverCount()- Returns:
- number of registered learning drivers
-