// discover what properties it should prompt a human for in order to get // enough information to connect to a database. Note that depending on // the values the human has supplied so far, additional values may become // necessary, so it may be necessary to iterate though several calls. // to getPropertyInfo. // // url The URL of the database to connect to. // // info A proposed list of tag/value pairs that will be sent on // connect open. // // Returns an array of DriverPropertyInfo objects describing possible // properties. This array may be an empty array if no // properties are required. //———————————————————————- — public DriverPropertyInfo[] getPropertyInfo( String url, java.util.Properties info) throws SQLException { DriverPropertyInfo prop[]; // Only one property required for the SimpleText driver, the // directory. Check the property list coming in. If the // directory is specified, return an empty list. if (info.getProperty(”Directory”) == null) { // Setup the DriverPropertyInfo entry prop = new DriverPropertyInfo[1]; prop[0] = new DriverPropertyInfo(”Directory”, null); prop[0].description = “Initial text file directory”; prop[0].required = false; } else { // Create an empty list prop = new DriverPropertyInfo[0]; } return prop; } Let s Get Connected Now that we can identify a driver to provide services for a given URL and get a list of the required and optional parameters necessary, it s time to establish a connection to the database. The connect method does just that, as shown in Listing 10.17, by taking a URL and connection property list and attempting to make a connection to the database. The first thing that connect should do is verify the URL (by making a call to acceptsURL). If the URL is not supported by the driver, a null value will be returned. This is the only reason that a null value should be returned. Any other errors during the connect should throw an SQLException.
Our unmatched NT experience allows us to provide the most reliable and affordable hosting for our customers, just check NT Web Hosting services.