Sybase JDBC LookUp Sample

(with NSAPI on Netscape Enterprise Server)


 

This sample will connect to a SQL Anywhere database, look up and display customer information for a customer with the specified first and last name.

This file contains instructions for running this sample with the Netscape Enterprise Server. For instructions on running the sample with either the Microsoft Internet Information Server or the Microsoft Personal Web Server, please refer to the file IJDBC_Lookup.html. This file will only provide the instructions to run this sample. For a more detailed explanation of the components, please refer to the file NetscapeInstall.html.

Click here for installation instructions.


 

Customer Information Submission Form using POST method

(Before submitting this form, you must modify the classpath, host and port fields. )

Please enter the first and last name of the customer whose information you want retrieved.

First name:

Last name:


 

Customer Information Submission Form using GET method

(Before submitting this form, you must modify the classpath, host and port fields. )

Please enter the first and last name of the customer whose information you want retrieved.

First name:

Last name:



 

Installation Instructions

To run this sample on your machine, you will need to install the following components:

 

 

Server Side Instructions

To configure the Netscape Enterprise Server

  1. Go to your \Netscape\Server\docs directory
  2. Create a file named service.wjava and add these statements to it:
        <HTML>
        <HEAD>
        <TITLE>Optima++ Java Netscape Service Placeholder</TITLE>
        </HEAD>
        <BODY>
        <BLOCKQUOTE>
        <FONT SIZE=+3>P</FONT><FONT SIZE=+1>laceholder for Optima++ Java
        support. If you see this file on your browser, you have not installed
        or setup the JAVANSAPI.DLL properly.
        </BODY>
        </HTML> 
  3. Save service.wjava and close the file
  4. Go to your \Netscape\Server\https-serverName\config directory, where serverName is the name of your Netscape Enterprise Server.
        For example: d:\Netscape\Server\https-mnguyen\config 
  5. Open the file obj.conf.
  6. Add this line after the last Init fn= statement (all on 1 line, without newlines):
        Init fn="load-modules" shlib="%Starbuck%/system/javansapi.dll"
        funcs="wjava-fn,wjava-ntrans"
            where %Starbuck% is the directory where Starbuck is installed
    
        For example:
            Init fn="load-modules" shlib="d:/starbuck20/system/javansapi.dll"
            funcs="wjava-fn,wjava-ntrans" 
  7.  Add this line after the <Object name="default"> statement:
        NameTrans fn=wjava-ntrans 
  8. Add these lines after </Object> statement that closes the <Object name="default">
    section:
        <Object name=wjava>
        Service fn=wjava-fn
        </Object> 
  9. Save obj.conf and restart your Netscape Enterprise Server

 

To configure the Open Server Gateway for a SQL Anywhere Database

  1. Install the Open Server Gateway components (SQL Anywhere Open Server Gateway and Sybase Open Server components) when installing SQL Anywhere Server.
  2. Check that your SYBASE environment variable is set to point to the directory where you've installed the Open Server Gateway components.
        For example: SYBASE = d:\sybase 
  3. Run \sybase\bin\sqledit.exe to provide an Open Server Gateway name for your SQL Anywhere database and configures your connection profile.
  4. Click on the Input Server Name box and type the Open Server Gateway name you want to give your SQL Anywhere database. The convention is to give the Open Server Gateway the same name as your SQL Anywhere database.
        For example: sademo 
  5. Click on Add to add this name to the list of Server Entries.
  6. From the Service Type list, select query to add a query service
  7. From the Platform list, select the appropriate platform (NT, dos, or win3).
  8. From the Net-Library Driver list, select NLWNSCK. This is the WinSock network-library driver.
  9. Click on the Connection Information/Network Address box. Then type your machine name, a comma and then the port number where client programs can access this SQL Anywhere database. Here, you can choose any unused port number.
        For example: MNGUYEN, 8000 
  10. Click Add Service to add this query service.
  11. From the Service Type list, select master to add a master service
  12. Repeat Steps 7, 8 and 9.
  13. From the File menu of the main SQLEDIT menu bar, click Save to save this sql.ini file.

  Check that you have the following information in your sql.ini file displayed in SQLEDIT:

 

To modify the classpath form field

The classpath field is the path to the Java class files for this sample as well as the path to the Starbuck Java class files. If you run this sample from Starbuck, Starbuck will copy the class files and this html file to your \Netscape\Server\docs\NJDBC_Lookup directory. From your HTML editor, modify the classpath field to point to the following directories

To modify the host form field

The host form field is the host name of your computer, not the Open Server Gateway name for the SQL Anywhere database. From your HTML editor, modify the host field to your machine name.

 

To modify the port form field

The host form field is the port number to connect to the SQL Anywhere database. From your HTML editor, modify the port field to the port number on your computer.

 

 

Client Side Instructions

To run this sample from Starbuck

  1. Start the SQL Anywhere database by clicking on the Start button on your Windows desktop, choosing Run and then typing in the following command (or by typing in the following at the command line in a DOS box):
        dbeng50 db_name 
            where db_name is the path to your SQL Anywhere database
    
        For example: dbeng50 d:\sqlany50\sademo.db 
  2. Start the Open Server Gateway for NT by typing in the following at the command line in a DOS box:
        dbos50 -v server_name
            where server_name is the Open Server Gateway name for your
            SQL Anywhere database. (The -v switch is for verbose mode.)
    
        For example: dbos50 -v sademo 
  3. Start the Netscape Enterprise Server
  4. Start Starbuck
  5. Open this sample project: IJDBC_Lookup.wxp
  6. From the View menu of the main Starbuck menu bar, click Targets
  7. In the Targets window, use the right button to click on NJDBC_LookUpWebApp. Then choose Run Options
  8. On the General page, click Publish, then run a web browser
  9. Click Configure and choose your Web browser
  10. Click on the Initial URL for the browser box and type in the following URL:
        http://localhost/NJDBC_Lookup/NJDBC_Lookup.html 
  11. Click OK
  12. Click the Publish tab. On the Publish page, click Copy the files to a folder
  13. Click in the Folder box and then type the path to your \Netscape\Server\docs\NJDBC_Lookup
        For example: d:\Netscape\Server\docs\NJDBC_Lookup\ 
  14. Click OK to finish
  15. To run this sample, from the Run menu of the main Starbuck menu bar, click Run
  16. In the Default Program window, click on NJDBC_LookUpWebApp and click OK
  17. Wait for your Web browser to load this file
  18. In the Customer Information Submission Form, click on the First Name box and then type the first name of the customer whose information you want to retrieve.
  19. In the Customer Information Submission Form, click on the Last Name box and then type the last name of the customer whose information you want to retrieve.
  20. Click on View Customer to view the customer's information
  21. Stop the Open Server Gateway for NT by typing in the following at the command line in a DOS box:
        dbosstop -S server_name -U userID -P password -x thx1138
            where server_name is the Open Server Gateway name for your 
                      SQL Anywhere database
                  userID is the user Id for the SQL Anywhere database
                  password is the password for the SQL Anywhere database
    
        For example: dbosstop -S sademo -U dba -P sql -x thx1138 

 

To run this sample from outside Starbuck

  1. Make sure that this html file and the class files for this project are copied to your \Netscape\Server\docs\NJDBC_Lookup directory. The class files for this project are located in %Starbuck%\samples\IJDBC_Lookup\Debug directory, where %Starbuck% is the directory where you installed Starbuck
  2. Start the SQL Anywhere database by clicking on the Start button on your Windows desktop, choosing Run and then typing in the following command (or by typing in the following at the command line in a DOS box):
        dbeng50 db_name 
            where db_name is the path to your SQL Anywhere database
    
        For example: dbeng50 d:\sqlany50\sademo.db 
  3. Start the Open Server Gateway for NT by typing in the following at the command line in a DOS box:
        dbos50 -v server_name
            where server_name is the Open Server Gateway name for your
            SQL Anywhere database. (The -v switch is for verbose mode.)
        
        For example: dbos50 -v sademo 
  4. Start the Netscape Enterprise Server
  5. Start your Web browser and type in the following URL:
        http://localhost/NJDBC_Lookup/NJDBC_Lookup.html 
  6. In the Customer Information Submission Form, click on the First Name box and then type the first name of the customer whose information you want to retrieve.
  7.  In the Customer Information Submission Form, click on the Last Name box and then type the last name of the customer whose information you want to retrieve.
  8. Click on View Customer to view the customer's information
  9. Stop the Open Server Gateway for NT by typing in the following at the command line in a DOS box:
        dbosstop -S server_name -U userID -P password -x thx1138
            where server_name is the Open Server Gateway name for your
                      SQL Anywhere database
                  userID is the user Id for the SQL Anywhere database
                  password is the password for the SQL Anywhere database
    
        For example: dbosstop -S sademo -U dba -P sql -x thx1138