Sybase JDBC LookUp Sample

(with NetImpact Dynamo)


 

This sample will connect to a SQL Anywhere database, look up and display customer information for a customer whose id number is 101.


 

Installation Instructions

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

 

 

Server Side Instructions

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 configure 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.

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

 

To configure NetImpact Dynamo via SQL Central

  1. Start SQL Central.
  2. From the Tools menu of the main SQL Central menu bar, click Connect and then choose NetImpact Dynamo to connect to NetImpact Dynamo.
  3. Click in the Connection name box and type
        Dynamo Demo 
  4. From the ODBC data source list, select NetImpact Dynamo Demo
  5. Click in the User ID box and type
        dba 
  6.  Click in the Password box and type
        sql 
  7. Click OK.
  8. If you want this Dynamo Demo to start up every time you load SQL Central, from the Tools menu of the main SQL Central menu bar, click Connection Profiles. Then choose Dynamo Demo from the Connection Profile list. Then click Set Startup. Now, the Use on Startup field should be set to Yes. Click Close to finish. Please note that this won't take effect until you restart SQL Central.
  9. Double click on the Dynamo Demo icon.
  10. Double click on the Site folder, then click on the system folder to go to \Site\system.
  11. Double click on the autoexec.ssc icon to open it.
  12. Insert the following statement after the last line of text, but before the line with -->:
        site.AddExtension( 'JAVA_DYNAMO', '%Starbuck%/system/javadynamo.dll' );
            where %Starbuck% is the directory where you installed Starbuck.
            Please note the use of forward slashes in the path.
    
        For example: 
            site.AddExtension( 'JAVA_DYNAMO', 'd:/starbuck20/system/javadynamo.dll' ); 
  13. From the File menu of the editor window for autoexec.ssc, click Save to Database to save
  14. Close autoexec.ssc
  15. In the main SQL Central window, use the right button to click on the autoexec.ssc icon. Then choose Execute to run this script. If there were no errors, the output screen will be blank.
  16. Click on the Site folder to move to \Site.
  17. Double click on the Add Template icon to create a new template
  18. Click in the box for the new template's name and type
        DJDBC_Lookup 
  19. Click Next. Enter a description for this template if you wish, then click Next.
  20. Click Next to not add a SQL statement and then click Finish to accept the default HTML format.
  21. Double click on the template DJDBC_Lookup.stm icon to open it
  22. Insert the following statement after the <H1></H1> line:
        <!--JAVA_DYNAMO
            DJDBC_LookUp
            classpath=$%Starbuck%/java/lib;%Starbuck%/samples/DJDBC_LookUp/Debug
            host
            port
            firstName
            lastName
        -->
    
        The first line in the script is the name of the Java class with main(),
        in this case DJDBC_LookUp. 
        The second line is the classpath to the Java class files. %Starbuck% refers
        to the directory where Starbuck is installed.
            Please note the use of forward slashes in the path.
        The third line is the host name of your computer.
        The fourth line is the port number to connect to the SQL Anywhere database
        The fifth line is the first name of the customer whose info you want to get
        The sixth line is the last name of the customer whose info you want to get
    
        For example:
            <!--JAVA_DYNAMO
                DJDBC_LookUp
                classpath=$d:/starbuck20/java/lib;d:/starbuck20/samples/DJDBC_LookUp/Debug
                mnguyen
                8000
                Michaels
                Devlin
            --> 
  23. From the File menu of the editor window for DJDBC_Lookup.stm, click Save to Database to save this template into the database
  24. Close DJDBC_Lookup.stm

 

 

Client Side Instructions

To run this sample from SQL Central

  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 SQL Central
  4. In the main SQL Central window, click on the Site folder to move to \Site.
  5. Use the right button to click on the DJDBC_Lookup.stm icon and choose View Output or Browse Output
  6. 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 a browser with Dynamo Personal Web Server

  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 Dynamo Personal Web Server
  4. Start your Web browser and type in the following URL:
        http://localhost/Site/DJDBC_LookUp.stm 
  5. 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