Helping ordinary people create extraordinary websites!
HOME TUTORIALS SCRIPTS WEB HOSTING BLOG FORUM
Get Our Newsletter
Email:

Using JDBC to Create Database Objects

By James W. Cooper
2003-05-24


The Query Result Dialog

public void paint(Graphics g)
{
String s[];
int x=0;
//compute the font height
int y =g.getFontMetrics().getHeight();
//compute an estimated column width
int deltaX = (int)1.5f*
  (g.getFontMetrics().stringWidth("wwwwwwwwwwwwww"));
//move through the table vector
for (int i=0; i< tables.size(); i++)
   {
   s  = (String[])tables.elementAt(i);
        //and draw each row from the string array
   for (int j =0; j< s.length; j++)
    {
    String st= s[j];
    g.drawString(st, x, y);
    x += deltaX;           //move over to next column
    }
   x = 0;                 //start a new row
   y += g.getFontMetrics().getHeight();
        //extra space between column labels and their data
   if (i == 0) y += g.getFontMetrics().getHeight();
   }
}

Figure 4: The queryDialog display in the dbFrame program, showing the results of the default query
Query Result



Tutorial Pages:
» What is a Database?
» Getting Data out of Databases
» Kinds of Databases
» ODBC
» What Is JDBC?
» Installing and Using JDBC
» Types of JDBC Drivers
» Two-Tier and Three-Tier Models
» Writing JDBC Code to Access Databases
» Registering Your Database with ODBC
» Connecting to a Database
» Accessing the Database
» The ResultSet
» ResultSetMetaData
» DatabaseMetaData
» Getting Information on Tables
» Executing SQL Queries, Printing out ResultSets, A Simple JDBC Program
» Building Higher Level JDBC Objects
» Building a Database Object, A Visual Database Program
» Executing a Query
» The Query Result Dialog
» Example Files
» Summary


First published by IBM DeveloperWorks


 | Bookmark
Related Tutorials:
» All about JAXP, Part 1
» Make Database Queries Without the Database
» Load List Values for Improved Efficiency
» 2 Ways To Implement Session Tracking
» A Simple Way to Read an XML File in Java
» Develop Aspect-Oriented Java Applications with Eclipse and AJDT