Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Column allows NULL not supported?

2 posts in JDBC Connect (product renamed to JConnect) Last posting was on 1997-08-12 20:43:49.0Z
Jason Kelley Posted on 1997-08-12 20:20:42.0Z
Message-ID: <33F0C59A.7DBC@investlearning.com>
Date: Tue, 12 Aug 1997 13:20:42 -0700
From: Jason Kelley <jkelley@investlearning.com>
Organization: Invest Learning
X-Mailer: Mozilla 2.0 (Win95; I; 16bit)
MIME-Version: 1.0
Subject: Column allows NULL not supported?
Content-Type: multipart/mixed; boundary="------------468518BF5A03"
Newsgroups: sybase.public.jdbcconnect
Lines: 70
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:387
Article PK: 252140

I can't seem to get jConnect to allow me to create a column which allows NULL. CREATE TABLE
commands in my Java code always end-up creating columns which do not allow NULL (as determined by
using Sybase Central to check the properties of the column). Issuing equivalent SQL commands in
ISQL give correct results - columns without the NOT NULL specified allow NULL.

The attached Java code (NotNullTest.java - please excuse the 8.3 truncation) attempts to create a
table with two columns. The notNullColumn specifies NOT NULL and the nullColumn does not.
Everything compiles and runs without any exceptions. When I go to Sybase Central and check the
properties of the columns, neither has the "Column allows NULL" box checked.

The attached ISQL command file (NotNullTest.sql - please excuse the 8.3 truncation) gives the
correct results when issued against the same database on the same server.

Does jConnect support "Column allows NULL"?

Environment information:
Windows 95
Sybase SQL Anywhere Network Server Version 5.5.02 Build #1495
running on my workstation with the sademo database loaded
note that sademo has the Allow_nulls_by_default option set to ON
Sybase SQL Anywhere Open Server Gateway Version 5.5.02 Build #1495
running on my workstation, listening on localhost:5001
jConnect for JDBC 2.1 Development and Unsupported Version
jConnect.class date 7-29-97 2:29p
JDK v1.1.3

TIA
Jason Kelley
Invest Learning

import java.sql.*;

class NotNullTest
{
public static void main (String[] args)
throws ClassNotFoundException, SQLException
{
Class.forName("com.sybase.jdbc.SybDriver");

Connection connection = DriverManager.getConnection(
"jdbc:sybase:Tds:localhost:5001", "dba", "sql");
Statement statement = connection.createStatement();

try
{
statement.executeUpdate("DROP TABLE NotNullTest");
}
catch(SQLException e)
{ /* ignore possible table not found exception */
}
statement.executeUpdate("CREATE TABLE NotNullTest (" +
"notNullField INT NOT NULL," +
"nullField INT)");

statement.close();
connection.close();
}
}

DROP TABLE NotNullTest;
CREATE TABLE NotNullTest (
notNullColumn INT NOT NULL,
nullColumn INT);


David Lance Wolf Posted on 1997-08-12 20:43:49.0Z
Message-ID: <33F0CB04.C4FDC354@sybase.com>
Date: Tue, 12 Aug 1997 13:43:49 -0700
From: David Lance Wolf <dwolf@sybase.com>
Organization: Sybase Professional Services
X-Mailer: Mozilla 4.01 [en] (Win95; U)
MIME-Version: 1.0
Subject: Re: Column allows NULL not supported?
X-Priority: 3 (Normal)
References: <33F0C59A.7DBC@investlearning.com>
Content-Type: multipart/mixed; boundary="------------39492252C975E3D5896F5BB0"
Newsgroups: sybase.public.jdbcconnect
Lines: 130
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:386
Article PK: 252135

Jason-

This is an issue with the OpenServer gateways connection and not
jConnect. Try your script by running it through the OSgateway, and
you'll see that the nullColumn is set as NOT NULL.

SQL Server defaults to NOT NULL by default, unlike SQL Anywhere which is
NULL by default (ANSI). When the OSgateway connects, it sets several
database options to emulate a SQL Server. I recomend explicitly setting
NULL/NOT NULL for portability anyway.

Dave Wolf
Sybase Professional Services

Find attached from the help file.

When Open Server Gateway connects to SQL Anywhere, it automatically sets
relevant database options to values that are compatible with SQL Server
default behavior. These options are set temporarily, for the duration of
the Open Server Gateway connection only. They can be overridden by the
client application at any time.
The database options that are set by Open Server Gateway on connection
are as follows:

Option Set to
ALLOW_NULLS_BY_DEFAULT OFF
ANSI_BLANKS ON
ANSI_INTEGER_OVERFLOW ON
AUTOMATIC_TIMESTAMP ON
CHAINED OFF
QUOTED_IDENTIFIER OFF
TSQL_HEX_CONSTANT ON
TSQL_VARIABLES ON

Jason Kelley wrote:

> I can't seem to get jConnect to allow me to create a column which
> allows NULL. CREATE TABLE
> commands in my Java code always end-up creating columns which do not
> allow NULL (as determined by
> using Sybase Central to check the properties of the column). Issuing
> equivalent SQL commands in
> ISQL give correct results - columns without the NOT NULL specified
> allow NULL.
>
> The attached Java code (NotNullTest.java - please excuse the 8.3
> truncation) attempts to create a
> table with two columns. The notNullColumn specifies NOT NULL and the
> nullColumn does not.
> Everything compiles and runs without any exceptions. When I go to
> Sybase Central and check the
> properties of the columns, neither has the "Column allows NULL" box
> checked.
>
> The attached ISQL command file (NotNullTest.sql - please excuse the
> 8.3 truncation) gives the
> correct results when issued against the same database on the same
> server.
>
> Does jConnect support "Column allows NULL"?
>
> Environment information:
> Windows 95
> Sybase SQL Anywhere Network Server Version 5.5.02 Build #1495
> running on my workstation with the sademo database
> loaded
> note that sademo has the Allow_nulls_by_default option
> set to ON
> Sybase SQL Anywhere Open Server Gateway Version 5.5.02 Build
> #1495
> running on my workstation, listening on localhost:5001
>
> jConnect for JDBC 2.1 Development and Unsupported Version
> jConnect.class date 7-29-97 2:29p
> JDK v1.1.3
>
> TIA
> Jason Kelley
> Invest Learning
>
>
> -------------------------------------------------------------------------------------------------------------
>
> import java.sql.*;
>
> class NotNullTest
> {
> public static void main (String[] args)
> throws ClassNotFoundException, SQLException
> {
> Class.forName("com.sybase.jdbc.SybDriver");
>
> Connection connection = DriverManager.getConnection(
> "jdbc:sybase:Tds:localhost:5001",
> "dba", "sql");
> Statement statement = connection.createStatement();
>
> try
> {
> statement.executeUpdate("DROP TABLE
> NotNullTest");
> }
> catch(SQLException e)
> { /* ignore possible table not found
> exception */
> }
> statement.executeUpdate("CREATE TABLE NotNullTest (" +
>
> "notNullField INT NOT NULL," +
> "nullField INT)");
>
> statement.close();
> connection.close();
> }
> }
>
>
> -------------------------------------------------------------------------------------------------------------
>
> DROP TABLE NotNullTest;
> CREATE TABLE NotNullTest (
> notNullColumn INT NOT NULL,
> nullColumn INT);


Download VCard vcard.vcf