Sybase Technical Library - Product Manuals Home
[Search Forms] [Previous Section with Hits] [Next Section with Hits] [Clear Search] Expand Search

Chapter 11 Network Access Using java.net [Table of Contents] Glossary

Java in Adaptive Server Enterprise

[-] Chapter 12 Reference Topics

Chapter 12

Reference Topics

This chapter presents information on several reference topics.

Assignments

This section defines the rules for assignment between SQL data items whose datatypes are Java-SQL classes.

Each assignment transfers a source instance to a target data item:

If the source is a variable or parameter, then it is a reference to an object in the Java VM. If the source is a column reference, which contains a serialization, then the rules for column references (see Java-SQL column references) yield a reference to an object in the Java VM. Thus, the source is a reference to an object in the Java VM.

Assignment rules at compile-time

  1. Define SC and TC as compile-time class names of the source and target. Define SC_T and TC_T as classes named SC and DT in the database associated with the target. Similarly, define SC_S and TC_S as classes named SC and DT in the database associated with the source.

  2. SC_T must be the same as TC_T or a subclass of TC_T.

Assignment rules at runtime

Assume that DT_SC is the same as DT_TC or its subclass.

Allowed conversions

You can use convert to change the expression datatype in these ways:

The result of the conversion is associated with the current database.

See "Using the SQL convert function for Java subtypes," for a discussion of the use of the convert function for Java subtypes.

Transferring Java-SQL objects to clients

When a value whose datatype is a Java-SQL object type is transferred from Adaptive Server to a client, the data conversion of the object depends on the client type:

Supported Java API packages, classes, and methods

Adaptive Server supports many but not all classes and methods in the Java API. In addition, Adaptive Server may impose security restrictions and implementation limitations. For example, Adaptive Server does not support all of the thread creation and manipulation facilities of java.lang.Thread.

The supported packages are installed with Adaptive Server and are always available. They cannot be installed by the user.This section lists:

Supported Java packages and classes

Unsupported Java packages and classes

Unsupported java.sql methods and interfaces

Invoking SQL from Java

Adaptive Server supplies a native JDBC driver, java.sql, that implements JDBC 1.1 specifications. It is described at http://www.javasoft.com. java.sql enables Java methods executing in Adaptive Server to perform SQL operations.

Special considerations

java.sql.DriverManager.getConnection( ) accepts these URLs:

When invoking SQL from Java some restrictions apply:

Transact-SQL commands from Java methods

You can use certain Transact-SQL commands in Java methods called within the SQL system. Table 12-1 lists Transact-SQL commands and whether or not you can use them in Java methods. You can find further information on most of these commands in the Sybase Adaptive Server Enterprise Reference Manual.

Support status of Transact-SQL commands

Command

Status

alter database

Not supported.

alter role

Not supported.

alter table

Supported.

begin ... end

Supported.

begin transaction

Not supported.

break

Supported.

case

Supported.

checkpoint

Not supported.

commit

Not supported.

compute

Not supported.

connect - disconnect

Not supported.

continue

Supported.

create database

Not supported.

create default

Not supported.

create existing table

Not supported.

create function

Supported.

create index

Not supported.

create procedure

Not supported.

create role

Not supported.

create rule

Not supported.

create schema

Not supported.

create table

Supported.

create trigger

Not supported.

create view

Not supported.

cursors

Not supported. Only "server cursors" are supported, that is, cursors that are declared and used within a stored procedure.

dbcc

Not supported.

declare

Supported.

disk init

Not supported.

disk mirror

Not supported.

disk refit

Not supported.

disk reinit

Not supported.

disk remirror

Not supported.

disk unmirror

Not supported.

drop database

Not supported.

drop default

Not supported.

drop function

Supported.

drop index

Not supported.

drop procedure

Not supported.

drop role

Not supported.

drop rule

Not supported.

drop table

Supported.

drop trigger

Not supported.

drop view

Not supported.

dump database

Not supported.

dump transaction

Not supported.

execute

Supported.

goto

Supported.

grant

Not supported.

group by and having clauses

Supported.

if...else

Supported.

insert table

Supported.

kill

Not supported.

load database

Not supported.

load transaction

Not supported.

online database

Not supported.

order by Clause

Supported.

prepare transaction

Not supported.

print

Not supported.

raiserror

Supported.

readtext

Not supported.

return

Supported.

revoke

Not supported.

rollback trigger

Not supported.

rollback

Not supported.

save transaction

Not supported.

set

See Table 12-2 for set options.

setuser

Not supported.

shutdown

Not supported.

truncate table

Supported.

union Operator

Supported.

update statistics

Not supported.

update

Supported.

use

Not supported.

waitfor

Supported.

where Clause

Supported.

while

Supported.

writetext

Not supported.

Table 12-2 lists set command options and whether or not you can use them in Java methods.

Support status of set command options

set command option

Status

ansinull

Supported.

ansi_permissions

Supported.

arithabort

Supported.

arithignore

Supported.

chained

Not supported. See Note 1.

char_convert

Not supported.

cis_rpc_handling

Not supported

close on endtran

Not supported

cursor rows

Not supported

datefirst

Supported

dateformat

Supported

fipsflagger

Not supported

flushmessage

Not supported

forceplan

Supported

identity_insert

Supported

language

Not supported

lock

Supported

nocount

Supported

noexec

Not supported

offsets

Not supported

or_strategy

Supported

parallel_degree

Supported. See Note 2.

parseonly

Not supported

prefetch

Supported

process_limit_action

Supported. See Note 2.

procid

Not supported

proxy

Not supported

quoted_identifier

Supported

replication

Not supported

role

Not supported

rowcount

Supported

scan_parallel_degree

Supported. See Note2.

self_recursion

Supported

session_authorization

Not supported

showplan

Supported

sort_resources

Not supported

statistics io

Not supported

statistics subquerycache

Not supported

statistics time

Not supported

string_rtruncation

Supported

stringsize

Supported

table count

Supported

textsize

Not supported

transaction iso level

Not supported. See Note 1.

transactional_rpc

Not supported

(1) set commands with options chained or transaction isolation level are allowed only if the setting that they specify is already in effect. That is, this kind of set command is allowed if it has no affect. This is done to support common coding practises in stored procedures.

(2) set commands pertaining to parallel degree are allowed but have no affect. This supports the use of stored procedures that set the parallel degree for other contexts.

Datatype mapping between Java and SQL

Adaptive Server maps SQL datatypes to Java types (SQL-Java datatype mapping) and Java scalar types to SQL datatypes (Java-SQL datatype mapping). Table 12-3 shows SQL-Java datatype mapping.

Mapping SQL datatypes to Java types

SQL type

Java type

char

String

varchar

String

nchar

String

nvarchar

String

text

String

numeric

java.math.BigDecimal

decimal

java.math.BigDecimal

money

java.math.BigDecimal

smallmoney

Java.math.BigDecimal

bit

boolean

tinyint

byte

smallint

short

integer

int

real

float

float

double

double precision

double

binary

byte[ ]

varbinary

byte[ ]

image

byte[ ]

datetime

java.sql.Timestamp

smalldatetime

java.sql.Timestamp

Table 12-4 shows Java-SQL datatype mapping.

Mapping Java scalar types to SQL datatypes

Java scalar type

SQL type

boolean

bit

byte

tinyint

short

smallint

int

integer

long

integer

float

real

double

double

Java-SQL identifiers

Description

Java-SQL identifiers are a subset of Java identifiers that can be referenced in SQL.

Syntax

java_sql_identifier ::= alphabetic character |     underscore (_) symbol
    [alphabetic character | arabic numeral |     underscore(_) symbol | 
    dollar ($) symbol ]

Usage

Delimited Identifiers

See also

For additional information about identifiers, see Chapter 5, "Transact-SQL Topics," in the Reference Manual.

Java-SQL class and package names

Description

To reference a Java-SQL class or package, use the following syntax:

Syntax

java_sql_class_name ::=  [java_sql_package_name.]java_sql_identifier
java_sql_package_name ::=
    [java_sql_package_name.]java_sql_identifier

Parameters

java_sql_class_name

The fully qualified name of a Java-SQL class in the current database.

java_sql_package_name

The fully qualified name of a Java-SQL package in the current database.

java_sql_identifier

See Java-SQL identifiers.

Usage

For Java-SQL class names:

For Java-SQL package names:

Java-SQL column declarations

Description

To declare a Java-SQL column when you create or alter a table, use the following syntax:

Syntax

java_sql_column ::= column_name  java_sql_class_name

Parameters

java_sql_column

Specifies the syntax of Java-SQL column declarations.

column_name

The name of the Java-SQL column.

java_sql_class_name

The name of a Java-SQL class in the current database. This is the "declared class" of the column.

Usage

See also

You use a Java-SQL column declaration only when you create or alter a table. See the create table and alter table information in the Reference Manual.

Java-SQL variable declarations

Description

Use Java-SQL variable declarations to declare variables and stored procedure parameters for datatypes that are Java-SQL classes.

Syntax

java_sql_variable  ::=  @variable_name java_sql_class_name
java_sql_parameter  ::=  @parameter_name java_sql_class_name

Parameters

java_sql_variable

Specifies the syntax of a Java-SQL variable in a SQL stored procedure.

java_sql_parameter

Specifies the syntax of a Java-SQL parameter in a SQL stored procedure.

java_sql_class_name

The name of a Java-SQL class in the current database.

Usage

A java_sql_variable or java_sql_parameter is always associated with the database containing the stored procedure.

See also

Refer to the Reference Manual for more information about variable declarations.

Java-SQL column references

Description

To reference a Java-SQL column, use the following syntax:

Syntax

column_reference ::=
    [ [ [database_name.]owner.]table_name.]column_name
    |  database_name..table_name.column_name

Parameters

column_reference

A reference to a column whose datatype is a Java-SQL class.

Usage

Java-SQL member references

Description

References a field or method of a class or class instance.

Syntax

member_reference ::=   class_member_reference |
    instance_member_reference
class_member_reference ::=  java_sql_class_name.method_name
instance_member_reference ::= instance_expression>>member_name
instance_expression ::= column_reference | variable_name
    | parameter_name | method_call | member_reference
member_name ::=  field_name | method_name

Parameters

member_reference

An expression that describes a field or method of a class or object.

class_member_reference

An expression that describes a static method of a Java-SQL class.

instance_member_reference

An expression that describes a static or dynamic method or field of a Java-SQL class instance.

java_sql_class_name

A fully qualified name of a Java-SQL class in the current database.

instance_expression

An expression whose datatype is a Java-SQL class.

member_name

The name of a field or method of the class or class instance.

Usage

Java-SQL method calls

Description

To invoke a Java-SQL method, which returns a single value, use the following syntax:

Syntax

method_call ::= member_reference ([parameters])
    |  new  java_sql_class_name ([parameters])
parameters ::= parameter [(, parameter)...]
parameter ::= expression

Parameters

method_call

An invocation of a static method, instance method, or class constructor. A method call can be used in an expression where a non-constant value of the method's datatype is required.

member_reference

A member reference that denotes a method.

parameters

The list of parameters to be passed to the method. If there are no parameters, include empty parentheses.

Usage

Method overloading

Datatype of method calls

Runtime results


Chapter 11 Network Access Using java.net [Table of Contents] Glossary