Sybase JDBC Driver Sample Program
The Sybase JDBC Driver Sample is a Java application that will demonstrate the use of the Sybase JDBC
Driver to connect to either a SQL Server or a SQL Anywhere database using the Sybase TDS protocol.
Installation Instructions
To run this sample on your machine, you will need to install the following components:
- Microsoft Java VM
- SQL Server (and a SQL Server database) and / or SQL Anywhere (and a SQL Anywhere database)
- Open Server Gateway components from SQL Anywhere
SQL Server Database
To connect to a SQL Server Database
- Go to the "Jato Samples"\Sybase_JDBC_Driver\Debug subfolder of your Jato installation folder.
- Run the Java application sample using a Java interpreter.
For example: jview Sybase_JDBC_Driver
- Fill in the connection information for the SQL Server database that you want to connect to.
Host refers to the host name
Port refers to the port number
Database refers to database on the SQL Server
User ID refers to the User Id
Password refers to the Password
For example:
Host = mnguyen
Port = 5000
Database = pubs2
UserID = sa
Password =
- Click on SQL Server Database
- Click on the Query box and type in your query.
For example: select * from authors
- Click on Get Query
SQL Anywhere Database
To configure the Open Server Gateway for a SQL Anywhere Database
- Install the Open Server Gateway components (SQL Anywhere Open Server Gateway and
Sybase Open Server components) when installing SQL Anywhere Server.
- 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
- Run \sybase\bin\sqledit.exe to provide an Open Server Gateway name for your SQL
Anywhere database and configure your connection profile.
- 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
- Click on Add to add this name to the list of Server Entries.
- From the Service Type list, select query to add a query service
- From the Platform list, select the appropriate platform (NT, dos, or win3).
- From the Net-Library Driver list, select NLWNSCK. This is the WinSock network-library driver.
- 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
- Click Add Service to add this query service.
- From the Service Type list, select master to add a master service
- Repeat Steps 7, 8 and 9.
- 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:
- In the Server Entry list, an entry for your SQL Anywhere database resembling:
sademo
- From the Server Entry list, click on the name of your SQL Anywhere database:
sademo
- In the Connection Server Entry list, a query service entry resembling:
query = NLWNSCK, MNGUYEN, 8000
- In the Connection Server Entry list, a master service entry resembling:
master = NLWNSCK, MNGUYEN, 8000
To connect to a SQL Anywhere Database
- 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
- 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
- Go to the "Jato Samples"\Sybase_JDBC_Driver\Debug subfolder of your Jato installation folder.
- Run the Java application sample using a Java interpreter.
For example: jview Sybase_JDBC_Driver
- Fill in the connection information for the SQL Anywhere database that you want to connect to.
Host refers to the host name
Port refers to the port number
User ID refers to the User Id
Password refers to the Password
NOTE: Database does not apply when connecting to SQL Anywhere
For example:
Host = mnguyen
Port = 8000
UserID = dba
Password = sql
- Click on the Query box and type in your query.
For example: select * from product
- Click on Get Query
- 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
D