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:

 

To configure the Open Server Gateway for a SQL Anywhere Database

  1. When installing your SQL Anywhere Server, you must intall the Open Server Gateway components. Therefore, make sure that you install the 'SQL Anywhere Open Server Gateway' and 'Sybase Open Server components'.
  2. Make sure that your SYBASE environment variable is set to point to the directory where you've installed the Open Server Gateway components.
  3. Run 'sqledit.exe' (which should be located under the \sybase directory) to provide an Open Server Gateway name for your SQL Anywhere database and to configure its connection profile.
  4. Add an Open Server Gateway name for your SQL Anywhere database under 'Input Server Name'. The convention is to give it the same name as your SQL Anywhere database. Then click 'Add'.
    For example: "sademo"
  5. To add a Query Service, first click on 'query' on 'Service Type:' under 'Connection Service Entry'.
  6. Click on the appropriate platform on 'Platform:'.
  7. Click on 'NLWNSCK' on 'Net-Library Driver:'.
  8. Under 'Connection Information/Network Address:', type in the machine name where the SQL Anywhere database is located. This typically is the name of the computer that you're currently working on. Then type a comma, followed by the port number where client programs can access this SQL Anywhere database. Here, you can typically choose any unused port number.
    For example: "MNGUYEN, 8000"
  9. Click on the 'Add Service' button to add this query service.
  10. To add a Master Service, click on 'master' on 'Service Type:' under 'Connection Service Entry'.
  11. Repeat Steps 6, 7 and 8.
  12. Save this 'sql.ini' file by choosing 'File' and 'Save'.

To configure NetImpact Dynamo via SQL Central

  1. Run SQL Central and connect to NetImpact Dynamo by clicking on Tools\Connect\NetImpact Dynamo
  2. Type in "Dynamo Demo" for 'Connection name', choose "NetImpact Dynamo Demo" for 'ODBC data source' and type in "dba" for 'User ID:' and "sql" for 'Password'. Then click on Ok.
  3. If you want this Dynamo Demo to start up every time you load SQL Central, click on 'Tools\Connection Profiles'. Then choose "Dynamo Demo" and click on 'Set Startup". Now, the field for 'Use on Startup' should be set to 'Yes'. Please note that this won't take effect until you restart SQL Central
  4. Now double click on the "Dynamo Demo" icon and go to \Site\system.
  5. Double click on the file 'autoexec.ssc' and insert this statement after the last line of typing, but before the line with '-->':
    -- BEGIN CUT HERE --
    site.AddExtension( 'JAVA_DYNAMO', '%Starbuck%/system/javadynamo.dll' );
    -- END CUT --
    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' );
  6. Now save the file by clicking on 'File\Save to Database'. Now close the file
  7. Execute this script by right-clicking on the 'autoexec.ssc' icon. If there were no errors, the output screen will be blank.
  8. Create a new template by double-clicking on the "Add Template". You don't want a SQL statement and can accept all the defaults. Double click on the icon of your new template and add this tag:
    --- BEGIN CUT HERE --
    <!--JAVA_DYNAMO
    DJDBC_LookUp
    classpath=$d:/starbuck20/java/lib;d:/dev/DJDBC_LookUp/Debug
    host
    port

    -->
    -- END CUT --
    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 for the Microsoft Java VM. Type '$' followed immediately by the path to the directory where your "Starbuck" Java class files are stored and then follwed by the path to the class files for the 'DJDBC_LookUpr' project. The Java class files are in the \Debug directory of the project. Again, please note the use of forward slashes in the paths.
    * The third line is the host name of your computer (where the SQL Anywhere database resides), not the Open Server Gateway name for the SQL Anywhere database. For example: "mnguyen". The fourth line is the port number to connect to the SQL Anywhere database. For example: 8000.*
  9. Click on 'File\Save to Database' to save this template into the database

To run this sample from SQL Central

  1. Start the SQL Anywhere database by clicking on your 'Start Button' and 'Run' and typing in the following, or by simply typing in the following at the command line (in a DOS box):
    "dbeng50 db_name", where db_name is the name of your SQL Anywhere database (with path)
    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
    For example: "dbos50 -v sademo"
  3. Right click on the new template you created in Step 9 when configuring NetImpact Dynamo and choose 'View Output'
  4. To stop the Open Server Gateway for NT, type 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 and password 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 your 'Start Button' and 'Run' and typing in the following, or by simply typing in the following at the command line (in a DOS box):
    "dbeng50 db_name", where db_name is the name of your SQL Anywhere database (with path)
    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
    For example: "dbos50 -v sademo"
  3. Fire up the Dynamo Personal Web Server
  4. From your browser, type in the following URL:
    "http://localhost/template_name"
    where template_name is the path to the new template you created in Step 5 when configure NetImpact Dynamo.
    For example, if my template name was called 'test.stm' and it was saved in the \Site\app (in SQL Central), then I would type: "http://localhost/Site/app/test.stm"
  5. To stop the Open Server Gateway for NT, type 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 and password the password for the SQL Anywhere database.
    For example: "dbosstop -S sademo -U dba -P sql -x thx1138"