Introduction to Sybase, Part 2
Last month, we installed a Sybase database server. This month, we will install a client to access our server. First, we need to understand how the Sybase network interface works.
A Sybase client must create a network connection to a database server when it needs to access resources in the database (see Figure 1). Sybase has created a protocol to communicate over the network. This protocol is called the Tabular Data Stream (TDS) protocol. It operates on top of other networking protocols such as TCP/IP on UNIX systems or IPX/SPX on Novell networks. TDS is a proprietary protocol and not documented by Sybase. Fortunately, Sybase has created client libraries which can be used to communicate with the server. A group of people have tried to reverse-engineer the TDS protocol. Look at http://sunsite.unc.edu/freetds/ for more information.
Sybase supports two interfaces to the database. DB-Library is an API that has been used for quite awhile in Sybase products. I believe it is supported for backwards compatibility, and may not be supported in a future version of the product. CT-Library is the API Sybase created for version 10 and higher products. It supports advanced features such as cursors and asynchronous query processing. You don't need to understand these features to do basic processing with your database server. We will use CT-Library to communicate with our server.
We could write our client using C or C++. The libraries required to do this are included with the server. Look for examples in the sample directory under the server directory. There is a subdirectory for DB-Library and one for CT-Library. We don't have to use C or C++, however. An extension to the Perl language called sybperl enables the use of Perl to write clients to access the database.
Most Linux distributions come with the Perl language. On my system, I have installed Red Hat 5.1 which includes Perl version 5 by default. Fortunately, it is possible to install sybperl without recompiling Perl. Using this method precludes the use of the DB-Library, which is why we have chosen to use CT-Library.
If Perl is not installed on your system, install it now. If your distribution does not provide perl, you can download the source from CPAN (http://www.cpan.org/).
First, we must download sybperl from http://www.perl.com/CPAN-local/authors/Michael_Peppler/
The newest version available at the time of this writing is version 2.09_05 in the file sybperl-2.09_05.tar.gz (148KB). Change directories to the location of the sybperl tar file, and issue the command:
Change to the sybperl directory just created, and edit the CONFIG file. In the line DBLIBVS=1000, change the 1000 to 0. Make sure the line SYBASE=/opt/sybase contains the correct directory for the Sybase server. The line EXTRA_LIBS=-ltli must be changed to EXTRA_LIBS=-linsck.
We will build sybperl to work with CT-library. Most Linux distributions come with the Berkeley DB library. If Perl is configured to use this library, a conflict arises when using DB-library at the same time, since both use the call open_database. If you recompile Perl to leave out the Berkeley DB library, you can leave the line DBLIBVS=1000 in the CONFIG file and use DB-library.
Save the changes to the CONFIG file, then issue this command:
This will create a file that will build the software. It looks for the Perl installation in your path. If Perl isn't in your path, you'll need to change your path to include it. Now issue the make command to build the software; it will take a few minutes to run. sybperl has tests that can be run to ensure it is built properly. To run these tests, edit the PWD file to put your sa password and the name of your Sybase server on the proper lines. If you installed the server following the directions in the last issue, the name of the server is linux_dev. Save the file, then type the command
make testThis command will run a series of tests. If everything is working properly, the message “All tests successful” will be printed.
Now, let's install sybperl. If your Perl installation is in a directory that requires root access to modify, change to root using su. Run the command
Perl and sybperl are now installed, so it is time to write some programs.
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
|Non-Linux FOSS: Seashore||May 10, 2013|
|Trying to Tame the Tablet||May 08, 2013|
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- New Products
- The Pari Package On Linux
- What's the tweeting protocol?
- Trying to Tame the Tablet
- This is the easiest tutorial
1 hour 4 min ago
- Ahh, the Koolaid.
6 hours 42 min ago
- git-annex assistant
12 hours 42 min ago
- direct cable connection
13 hours 4 min ago
- Agreed on AirDroid. With my
13 hours 14 min ago
- I just learned this
13 hours 19 min ago
13 hours 49 min ago
- not living upto the mobile revolution
16 hours 40 min ago
- Deceptive Advertising and
17 hours 16 min ago
- Let\'s declare that you have
17 hours 16 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.