WebLogic Server 7.0 Code Examples, BEA Systems, Inc.

examples.jdbc.datasource
Class simplesqlServlet

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--examples.jdbc.datasource.simplesqlServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class simplesqlServlet
extends javax.servlet.http.HttpServlet

This servlet demonstrates using a DataSource to get a connection to a database and execute a simple sql query using the connection. The example uses the Pointbase database management system, provided in an evaluation version with WebLogic Server.

Build the Example

  1. Open a new command shell.

  2. Set up this development shell as described in Setting up Your Environment for Building and Running the Examples.
  3. Compile the example by executing an ant build script or a command.

    • An ant build script is available in the samples\examples\jdbc\datasource directory. Enter the following command to execute the build script:

       ant
    • Enter the following command to compile the example:

      javac -d %EX_WEBAPP_CLASSES% simplesqlServlet.java

  • Start WebLogic Server with the examples configuration.

    Configure the Server

    1. Make sure that the examplesWebApp is deployed on your server.

    2. Use the Administration Console to confirm that the examples-dataSource-demoPool DataSource is deployed on the examplesServer. For more information see JDBC Data Sources.

    Run the Example

    1. Use a web browser to load the following URL:
      http://localhost:7001/examplesWebApp/simplesqlServlet

    There's more

    For more information on servlets see Programming WebLogic HTTP Servlets.

    Author:
    Copyright (c) 1996-98 by WebLogic, Inc. All Rights Reserved., Copyright (c) 1999-2002 by BEA Systems, Inc. All Rights Reserved.

    Constructor Summary
    simplesqlServlet()
               
     
    Method Summary
     void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
               
     
    Methods inherited from class javax.servlet.http.HttpServlet
    , doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
     
    Methods inherited from class javax.servlet.GenericServlet
    destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    simplesqlServlet

    public simplesqlServlet()
    Method Detail

    service

    public void service(javax.servlet.http.HttpServletRequest req,
                        javax.servlet.http.HttpServletResponse res)
                 throws java.io.IOException
    Overrides:
    service in class javax.servlet.http.HttpServlet

    Documentation is available at
    http://e-docs.bea.com/wls/docs70

    Copyright © 2002 BEA Systems, Inc. All Rights Reserved.