Class JdbcExamples

java.lang.Object
net.jrodolfo.java_evolution.java01.jdbc.JdbcExamples

public class JdbcExamples extends Object
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.

  • Constructor Details

    • JdbcExamples

      public JdbcExamples()
  • Method Details

    • registerLearningDriver

      public JdbcExamples.LearningDriver registerLearningDriver(String urlPrefix)
      Registers a driver that accepts URLs beginning with the supplied prefix.
    • deregisterDriver

      public void deregisterDriver(JdbcExamples.LearningDriver driver)
      Removes a previously registered learning driver.
    • openConnection

      public JdbcExamples.LearningConnection openConnection(String jdbcUrl) throws SQLException
      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