December 24th, 2007
// Get the property information DriverPropertyInfo info[] = d.getPropertyInfo(url, props); // Just dump them out System.out.println(”Number of properties: ” + info.length); for (int i=0; i < info.length; i++) { System.out.println("nProperty " + (i + 1)); System.out.println("Name: " + info[i].name); System.out.println("Description: " + info[i].description); System.out.println("Required: " + info[i].required); System.out.println("Value: " + info[i].value); System.out.println("Choices: " + info[i].choices); } } catch (SQLException ex) { System.out.println ("nSQLException(s) caughtn"); // Remember that SQLExceptions may be chained together while (ex != null) { System.out.println("SQLState: " + ex.getSQLState()); System.out.println("Message: " + ex.getMessage()); System.out.println (""); ex = ex.getNextException (); } } } } Listing 10.15 produces the following output: Number of properties: 1 Property 1 Name: Directory Description: Initial text file directory Required: false Value: null Choices: null It doesn t take a lot of imagination to envision an application or applet that gathers the property information and prompts the user in order to connect to the database. The actual code to implement the getPropertyInfo method for the SimpleText driver is very simple, as shown in Listing 10.16. Listing 10.16 Implementing the getPropertyInfo method. //---------------------------------------------------------------------- -- // getPropertyInfo - JDBC API // // The getPropertyInfo method is intended to allow a generic GUI tool to
Adult web hosting has rich experience in providing unique solutions for the customer’s needs, just check frontpage web hosting services.