Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Query Class Reference

List of all members.

Public Member Functions

 Query (Connection conn, PrintWriter pw)
 Query (Connection conn, PrintWriter pw, String sql)
void execute (String sql)
void query (String sql)
void printSql (String sql)
void close ()

Static Public Member Functions

static void rethrow (Throwable e)

Public Attributes

Statement s
ResultSet r
PrintWriter pw

Static Public Attributes

static final boolean DEBUG = false

Detailed Description

Definition at line 12 of file Query.java.


Constructor & Destructor Documentation

Query::Query Connection  conn,
PrintWriter  pw
[inline]
 

Definition at line 20 of file Query.java.

00021   {
00022     this(conn, pw, null);
00023   }

Query::Query Connection  conn,
PrintWriter  pw,
String  sql
[inline]
 

Definition at line 25 of file Query.java.

References query(), and s.

00026   {
00027     this.pw = pw;
00028     try
00029     {
00030       s = conn.createStatement();
00031       if (sql != null) query(sql);
00032     }
00033     catch(SQLException e)
00034     {
00035       Widget.ShowException(e, pw);
00036     }
00037   }


Member Function Documentation

void Query::close  )  [inline]
 

Definition at line 75 of file Query.java.

References pw, r, and s.

00076   {
00077     try
00078     {  
00079       try
00080       {
00081         if (r != null)
00082         {
00083           r.close();
00084           r = null;
00085         }
00086       }
00087       finally
00088       {
00089         s.close();
00090         s = null;
00091       }
00092     }
00093     catch (SQLException e)
00094     {
00095       Widget.ShowException(e, pw);
00096     }
00097   }

void Query::execute String  sql  )  [inline]
 

Definition at line 39 of file Query.java.

References DEBUG, printSql(), pw, and s.

00040   {
00041     if (DEBUG) printSql(sql);
00042     try
00043     {
00044       s.executeUpdate(sql);
00045     }
00046     catch (SQLException e)
00047     {
00048       pw.println("<h2>Failed to execute SQL Statement:</h2>");
00049       printSql(sql);
00050       Widget.ShowException(e, pw);
00051     }
00052   }

void Query::printSql String  sql  )  [inline]
 

Definition at line 70 of file Query.java.

References pw.

00071   {
00072     pw.println("<pre style=\"background-color: #EEEEEE\">" + sql + "</pre>");
00073   }

void Query::query String  sql  )  [inline]
 

Definition at line 54 of file Query.java.

References DEBUG, printSql(), pw, r, and s.

00055   {
00056     if (DEBUG) printSql(sql);
00057     try
00058     {
00059       if (r != null) r.close();
00060       r = s.executeQuery(sql);
00061     }
00062     catch (SQLException e)
00063     {
00064       pw.println("<h2>Failed to execute SQL Query:</h2>");
00065       printSql(sql);
00066       Widget.ShowException(e, pw);
00067     }
00068   }

static void Query::rethrow Throwable  e  )  [inline, static]
 

Definition at line 99 of file Query.java.

00100   {  
00101     if (e instanceof RuntimeException)
00102       throw (RuntimeException) e;
00103     if (e instanceof Error)
00104       throw (Error) e;
00105     else // should never happen
00106       throw new Error("Unknown Exception caught", e);
00107   }


Member Data Documentation

final boolean Query::DEBUG = false [static]
 

Definition at line 18 of file Query.java.

PrintWriter Query::pw
 

Definition at line 16 of file Query.java.

ResultSet Query::r
 

Definition at line 15 of file Query.java.

Statement Query::s
 

Definition at line 14 of file Query.java.


The documentation for this class was generated from the following file:
Generated on Mon Mar 6 23:34:35 2006 by  doxygen 1.4.4