dods.servers.sql
Class dodsSQLServlet

java.lang.Object
  extended by HttpServlet
      extended by dods.servlet.DODSServlet
          extended by dods.servers.sql.dodsSQLServlet
Direct Known Subclasses:
drds

public abstract class dodsSQLServlet
extends DODSServlet

This extension of DODSServlet adds JDBC connection functionality to the servlet design. Because of the unusual nature of DBMS systems with respect to other types of data archives, the usual procedures for retrieving data in a DODS server needed to be changed. This class, dodsSQLServlet, encapsulates the logic for interacting with a DBMS. This includes getting the client's DODS request, changing it to an SQL query, querying the DBMS (using JDBC) and then collecting the reply and sending the returned data to the client.

The information for making the JDBC connection should be located in the iniFile object that is inflated by the doGet() method of the parent class DODSServlet. The section in the iniFile should look like:

 [JDBC]
 Driver            =    the.name.of.the.jdbc.driver
 ConnectionURL     =    jdbc:somevendor://targetmachine:port
 username          =    guest
 password          =
 MaxResponseLength =    300
 

Author:
Nathan David Potter
See Also:
doGet(), #loadIniFile()

Constructor Summary
dodsSQLServlet()
           
 
Method Summary
 Statement connect2DB(requestState rs)
           
 void doGetDODS(HttpServletRequest request, HttpServletResponse response, requestState rs)
          Handler for the client's data request.
protected  GuardedDataset getDataset(requestState rs)
          Supress this method (just pass through it) we need a special DDS here, and thus this method gets replaced by getSQLDDS().
abstract  String getServerVersion()
          This function must be implemented locally for each DODS server.
protected abstract  GuardedSQLDataset getSQLDataset(requestState rs)
          This function must be implemented locally for each DODS server.
 void init()
          Intitializes the servlet.
 void printColumnNames(ResultSetMetaData m, PrintStream dOut)
          Read the meta data stream and print up column names with type information
 void processResult(ResultSet result, PrintStream dOut)
           
 
Methods inherited from class dods.servlet.DODSServlet
anyExceptionHandler, badURL, dodsExceptionHandler, doGet, doGetASC, doGetCatalog, doGetDAS, doGetDDS, doGetDIR, doGetHELP, doGetHTML, doGetINFO, doGetStatus, doGetVER, getDAS, getServerName, isTheClientCompressed, openCachedDAS, openCachedDDS, parseExceptionHandler, printCatalog, printStatus, probeRequest, processDodsURL, sendDODSError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

dodsSQLServlet

public dodsSQLServlet()
Method Detail

getSQLDataset

protected abstract GuardedSQLDataset getSQLDataset(requestState rs)
                                            throws DODSException,
                                                   IOException,
                                                   ParseException
This function must be implemented locally for each DODS server. It should do the following:

Parameters:
dataSet - the name of the data set requested.
Throws:
DODSException
IOException
ParseException
See Also:
ServerDDS, sqlServerFactory, test_ServerFactory

getDataset

protected GuardedDataset getDataset(requestState rs)
                             throws DODSException,
                                    IOException,
                                    ParseException
Supress this method (just pass through it) we need a special DDS here, and thus this method gets replaced by getSQLDDS().

Specified by:
getDataset in class DODSServlet
Parameters:
dataSet - the name of the data set requested.
Returns:
The ServerDDS object all parsed and ready to roll.
Throws:
DODSException
IOException
ParseException
See Also:
ServerDDS, sqlServerFactory, test_ServerFactory

getServerVersion

public abstract String getServerVersion()
This function must be implemented locally for each DODS server. It should return a String cointaining the DODS Server Version...

Specified by:
getServerVersion in class DODSServlet

init

public void init()
          throws ServletException
Intitializes the servlet. Init (at this time) basically sets up the object dods.util.Debug from the debuggery flags in the servlet InitParameters. The Debug object can be referenced (with impunity) from any of the dods code...

Overrides:
init in class DODSServlet
Throws:
ServletException

doGetDODS

public void doGetDODS(HttpServletRequest request,
                      HttpServletResponse response,
                      requestState rs)
               throws IOException,
                      ServletException
Handler for the client's data request. Requires the getSQLDDS() method implemented by each server localization effort.

Once the DDS has been parsed, the projection is determine by proccesing the constraint expression. The SQLDDS is then asked to convert it's projection and selection information into an SQL query. This query is then submitted to the DBMS. The result set is then read into the SQLDDS. In the the process, the data is returned to the client. Neat, eh?

Overrides:
doGetDODS in class DODSServlet
Parameters:
request - The client's HttpServletRequest request object.
response - The server's HttpServletResponse response object.
dataSet - Name of the datset whose data is requested.
constraintExpression - Constraint expression recieved from the client. This is used (if it's not just empty) subset the data in the dataset.
Throws:
IOException
ServletException

connect2DB

public Statement connect2DB(requestState rs)
                     throws SQLException,
                            IOException
Throws:
SQLException
IOException

processResult

public void processResult(ResultSet result,
                          PrintStream dOut)
                   throws SQLException,
                          IOException
Throws:
SQLException
IOException

printColumnNames

public void printColumnNames(ResultSetMetaData m,
                             PrintStream dOut)
                      throws SQLException
Read the meta data stream and print up column names with type information

Throws:
SQLException