dods.servers.sql
Class dodsSQLServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bydods.servlet.DODSServlet
              extended bydods.servers.sql.dodsSQLServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig
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(), Serialized Form

Constructor Summary
dodsSQLServlet()
           
 
Method Summary
 void doGetDODS(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, ReqState rs)
          Handler for the client's data request.
protected  GuardedDataset getDataset(ReqState rs)
          Supress this method (just pass through it) we need a special DDS here, and thus this method gets replaced by getSQLDDS().
abstract  java.lang.String getServerVersion()
          This function must be implemented locally for each DODS server.
protected abstract  GuardedSQLDataset getSQLDataset(ReqState rs)
          This function must be implemented locally for each DODS server.
 void init()
          Intitializes the servlet.
 void printColumnNames(java.sql.ResultSetMetaData m, java.io.PrintStream dOut)
          Read the meta data stream and print up column names with type information
 void processResult(java.sql.ResultSet result, java.io.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 javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
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(ReqState rs)
                                            throws DODSException,
                                                   java.io.IOException,
                                                   ParseException
This function must be implemented locally for each DODS server. It should do the following:

Parameters:
rs - The ReqState object containing the particulars of this client request..
Throws:
DODSException
java.io.IOException
ParseException
See Also:
ServerDDS, sqlServerFactory, test_ServerFactory

getDataset

protected GuardedDataset getDataset(ReqState rs)
                             throws DODSException,
                                    java.io.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:
rs - The ReqState object containing the particulars of this client request..
Returns:
The ServerDDS object all parsed and ready to roll.
Throws:
DODSException
java.io.IOException
ParseException
See Also:
ServerDDS, sqlServerFactory, test_ServerFactory

getServerVersion

public abstract java.lang.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 javax.servlet.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:
javax.servlet.ServletException

doGetDODS

public void doGetDODS(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response,
                      ReqState rs)
               throws java.io.IOException,
                      javax.servlet.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.
rs - The ReqState object containing the particulars of this client request.. This is used (if it's not just empty) subset the data in the dataset.
Throws:
java.io.IOException
javax.servlet.ServletException

processResult

public void processResult(java.sql.ResultSet result,
                          java.io.PrintStream dOut)
                   throws java.sql.SQLException,
                          java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

printColumnNames

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

Throws:
java.sql.SQLException