Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
476
Chapter 18 JDBC and Database Connection Pooling
Listing 18.6  DatabaseUtilities.java (continued)
          row[i 1] = entry;
        }
        dbResults.addRow(row);
      }
      if (close) {
        connection.close();
      }
      return(dbResults);
    } catch(SQLException sqle) {
      System.err.println("Error connecting: " + sqle);
      return(null);
    } 
  }
  /** Build a table with the specified format and rows. */
  
  public static Connection createTable(String driver,
                                       String url,
                                       String username,
                                       String password,
                                       String tableName,
                                       String tableFormat,
                                       String[] tableRows,
                                       boolean close) {
    try {
      Class.forName(driver);
      Connection connection =
        DriverManager.getConnection(url, username, password);
      return(createTable(connection, username, password,
                         tableName, tableFormat,
                         tableRows, close));
    } catch(ClassNotFoundException cnfe) {
      System.err.println("Error loading driver: " + cnfe);
      return(null);
    } catch(SQLException sqle) {
      System.err.println("Error connecting: " + sqle);
      return(null);
    } 
  }
  /** Like the previous method, but uses existing connection. */
  
  public static Connection createTable(Connection connection,
                                       String username,
                                       String password,
                                       String tableName,
                                       String tableFormat,
                                       String[] tableRows,
                                       boolean close) {
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved