O'Reilly logo

The Database Hacker's Handbook: Defending Database Servers by Bill Grindlay, John Heasman, Chris Anley, David Litchfield

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Stand-Out Features

Sybase has a number of features that distinguish it from other database systems, and in particular, distinguish it from Microsoft SQL Server.

Java-In-ASE

Sybase ASE supports Java extensively, incorporating its own VM and full interoperability with Transact-SQL. Sybase implements part 1 of the SQLJ standard, and extends the standard, for instance by permitting direct references to Java methods and classes (the standard stipulates the use of aliases). As an example, the following transact SQL will raise an exception if the host 192.168.1.1 is not listening on TCP port 22:

declare @s java.net.Socket
select @s = new java.net.Socket( "192.168.1.1", 22 )
select @s>>"close"()

As you can see, it is possible to declare transact-sql variables of Java types, instantiate objects using parameterized constructors, and call functions.

Here's a quick run-through of the preceding example:

declare @s java.net.Socket

This declares a Transact-SQL variable in the normal way, but using the “Socket” type from the Java “net” standard package.

select @s = new java.net.Socket( "192.168.1.1", 22 )

This instantiates @s with a newly created socket using the (java.lang.String, java.lang.Integer) constructor. It's fortunate that Sybase implements this syntax because many objects in Java require creation via a parameterized constructor to be useful. In this case, we're creating the object and attempting to connect to the IP address “192.168.1.1” on TCP port 22. If we cannot connect to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required