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.

Error with Sybase's JDBC drivers, stored procedures with output parameters, java.sql.Date and datetimes?

2 posts in JDBC Connect (product renamed to JConnect) Last posting was on 1997-04-17 21:46:41.0Z
Emery Lapinski Posted on 1997-04-16 14:55:06.0Z
Message-ID: <3354E84A.1E55@panix.com>
Date: Wed, 16 Apr 1997 15:55:06 +0100
From: Emery Lapinski <ewl@panix.com>
Organization: Private Citizen
X-Mailer: Mozilla 3.0 (WinNT; I)
MIME-Version: 1.0
Subject: Error with Sybase's JDBC drivers, stored procedures with output parameters, java.sql.Date and datetimes?
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 123
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:986
Article PK: 252738

Hi All.

I'm having some wierd behavior using Sybase's JDBC drivers (jConnect) and
stored procedures that have datetime output parameters. The dates that I
get back seem to cycle based somehow on the input date. Here's some sample
output. Notice how the date seems to cycle. I've included a script to
create a trivial stored procedure and below that a java class that produced
this output. Is this a known bug? What is the workaround?

Thanks!
Emery

----- begin -----
Sybase jConnect (TM) for JDBC (TM) 2.1 Development and Unsupported Version
It is an unsupported product and is not intended for deployment. It does not
include free technical support. You can purchase technical support on an
annual or pay-per-issue basis. Discussion Newsgroup is available on
www.sybase.com. For additional information on services or run-time license,
please check Sybase website or call 1-800-8-SYBASE or +1-510-922-3500 outside
of the USA and Canada.

Copyright 1997 Sybase, Inc.
All Rights Reserved
month=0 date=1 in=1996-01-01 out=1996-01-01
month=0 date=2 in=1996-01-02 out=1996-01-02
month=0 date=3 in=1996-01-03 out=1996-01-03
month=0 date=4 in=1996-01-04 out=1996-01-04
month=0 date=5 in=1996-01-05 out=1996-01-05
month=0 date=6 in=1996-01-06 out=1996-01-06
month=0 date=7 in=1996-01-07 out=1995-12-31
month=0 date=8 in=1996-01-08 out=1996-01-01
month=0 date=9 in=1996-01-09 out=1996-01-02
month=0 date=10 in=1996-01-10 out=1996-01-03
month=0 date=11 in=1996-01-11 out=1996-01-04
month=0 date=12 in=1996-01-12 out=1996-01-05
month=0 date=13 in=1996-01-13 out=1996-01-06
month=0 date=14 in=1996-01-14 out=1995-12-31
month=0 date=15 in=1996-01-15 out=1996-01-01
...
month=1 date=1 in=1996-02-01 out=1996-02-04
month=1 date=2 in=1996-02-02 out=1996-02-05
month=1 date=3 in=1996-02-03 out=1996-02-06
month=1 date=4 in=1996-02-04 out=1996-01-31
month=1 date=5 in=1996-02-05 out=1996-02-01
month=1 date=6 in=1996-02-06 out=1996-02-02
month=1 date=7 in=1996-02-07 out=1996-02-03
month=1 date=8 in=1996-02-08 out=1996-02-04
month=1 date=9 in=1996-02-09 out=1996-02-05
...
month=2 date=1 in=1996-03-01 out=1996-03-05
month=2 date=2 in=1996-03-02 out=1996-03-06
month=2 date=3 in=1996-03-03 out=1996-02-29
month=2 date=4 in=1996-03-04 out=1996-03-01
month=2 date=5 in=1996-03-05 out=1996-03-02
month=2 date=6 in=1996-03-06 out=1996-03-03
month=2 date=7 in=1996-03-07 out=1996-03-04
month=2 date=8 in=1996-03-08 out=1996-03-05
month=2 date=9 in=1996-03-09 out=1996-03-06
month=2 date=10 in=1996-03-10 out=1996-02-29
month=2 date=11 in=1996-03-11 out=1996-03-01
month=2 date=12 in=1996-03-12 out=1996-03-02
month=2 date=13 in=1996-03-13 out=1996-03-03
month=2 date=14 in=1996-03-14 out=1996-03-04
...
------ end ------

Here's the script to create a stored procedure. It's trivial in that
it just copies the parameter back to itself.

----- begin -----
drop proc sp_check_jdbc_date
go
create proc sp_check_jdbc_date(@one datetime output)
as
begin
select @one = @one
end
go
------ end ------

Here's my sample java program that connects to the database and calls the
stored procedure. It prints the dat it passes in and the date it gets back.

----- begin -----
import java.io.* ;
import java.sql.* ;
import java.util.Properties ;
import com.sybase.utils.* ;

class Check
{
public static void main(String[] args)
{
try
{
Properties props = new Properties() ;
props.put("user", "elapinsk") ;
props.put("password", "nacmitg") ;

Class.forName("com.sybase.jdbc.SybDriver") ;
Connection connection = DriverManager.getConnection("jdbc:sybase:Tds:dubious:2025", props) ;

CallableStatement statement = connection.prepareCall("{call rptDB..sp_check_jdbc_date(?)}") ;
for(int month = 0 ; month < 12 ; month++)
for(int date = 1 ; date < 31 ; date++)
{
Date in = new Date(96, month, date) ;
statement.setDate(1, in) ;
statement.registerOutParameter(1, Types.DATE) ;
if(statement.execute()) System.err.println("results were not expected") ;
Date out = statement.getDate(1) ;
System.out.println("month=" + month + " date=" + date + " " + "in=" + in + " out=" + out) ;
}
}
catch(Exception e)
{
e.printStackTrace(System.err) ;
}
}
}

------ end ------


David Clegg Posted on 1997-04-17 21:46:41.0Z
Message-ID: <33569A41.4E7CF08C@sybase.com>
Date: Thu, 17 Apr 1997 14:46:41 -0700
From: David Clegg <davec@sybase.com>
X-Mailer: Mozilla 2.01 (X11; I; Linux 1.2.13 i586)
MIME-Version: 1.0
Subject: Re: Error with Sybase's JDBC drivers, stored procedures with output parameters, java.sql.Date and datetimes?
References: <3354E84A.1E55@panix.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 135
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:973
Article PK: 252725

It is a bug. Our internal tracking number will be 129201.
Workaround is to use setTimestamp() - and set the
hour/minute/second/nanos to 0/0/0/0.

Fix is in review, should be fixed and available for download in
a few days.

dave

> Hi All.
>
> I'm having some wierd behavior using Sybase's JDBC drivers (jConnect) and
> stored procedures that have datetime output parameters. The dates that I
> get back seem to cycle based somehow on the input date. Here's some sample
> output. Notice how the date seems to cycle. I've included a script to
> create a trivial stored procedure and below that a java class that produced
> this output. Is this a known bug? What is the workaround?
>
> Thanks!
> Emery
>
> ----- begin -----
> Sybase jConnect (TM) for JDBC (TM) 2.1 Development and Unsupported Version
> It is an unsupported product and is not intended for deployment. It does not
> include free technical support. You can purchase technical support on an
> annual or pay-per-issue basis. Discussion Newsgroup is available on
> www.sybase.com. For additional information on services or run-time license,
> please check Sybase website or call 1-800-8-SYBASE or +1-510-922-3500 outside
> of the USA and Canada.
>
> Copyright 1997 Sybase, Inc.
> All Rights Reserved
> month=0 date=1 in=1996-01-01 out=1996-01-01
> month=0 date=2 in=1996-01-02 out=1996-01-02
> month=0 date=3 in=1996-01-03 out=1996-01-03
> month=0 date=4 in=1996-01-04 out=1996-01-04
> month=0 date=5 in=1996-01-05 out=1996-01-05
> month=0 date=6 in=1996-01-06 out=1996-01-06
> month=0 date=7 in=1996-01-07 out=1995-12-31
> month=0 date=8 in=1996-01-08 out=1996-01-01
> month=0 date=9 in=1996-01-09 out=1996-01-02
> month=0 date=10 in=1996-01-10 out=1996-01-03
> month=0 date=11 in=1996-01-11 out=1996-01-04
> month=0 date=12 in=1996-01-12 out=1996-01-05
> month=0 date=13 in=1996-01-13 out=1996-01-06
> month=0 date=14 in=1996-01-14 out=1995-12-31
> month=0 date=15 in=1996-01-15 out=1996-01-01
> ...
> month=1 date=1 in=1996-02-01 out=1996-02-04
> month=1 date=2 in=1996-02-02 out=1996-02-05
> month=1 date=3 in=1996-02-03 out=1996-02-06
> month=1 date=4 in=1996-02-04 out=1996-01-31
> month=1 date=5 in=1996-02-05 out=1996-02-01
> month=1 date=6 in=1996-02-06 out=1996-02-02
> month=1 date=7 in=1996-02-07 out=1996-02-03
> month=1 date=8 in=1996-02-08 out=1996-02-04
> month=1 date=9 in=1996-02-09 out=1996-02-05
> ...
> month=2 date=1 in=1996-03-01 out=1996-03-05
> month=2 date=2 in=1996-03-02 out=1996-03-06
> month=2 date=3 in=1996-03-03 out=1996-02-29
> month=2 date=4 in=1996-03-04 out=1996-03-01
> month=2 date=5 in=1996-03-05 out=1996-03-02
> month=2 date=6 in=1996-03-06 out=1996-03-03
> month=2 date=7 in=1996-03-07 out=1996-03-04
> month=2 date=8 in=1996-03-08 out=1996-03-05
> month=2 date=9 in=1996-03-09 out=1996-03-06
> month=2 date=10 in=1996-03-10 out=1996-02-29
> month=2 date=11 in=1996-03-11 out=1996-03-01
> month=2 date=12 in=1996-03-12 out=1996-03-02
> month=2 date=13 in=1996-03-13 out=1996-03-03
> month=2 date=14 in=1996-03-14 out=1996-03-04
> ...
> ------ end ------
>
> Here's the script to create a stored procedure. It's trivial in that
> it just copies the parameter back to itself.
>
> ----- begin -----
> drop proc sp_check_jdbc_date
> go
> create proc sp_check_jdbc_date(@one datetime output)
> as
> begin
> select @one = @one
> end
> go
> ------ end ------
>
> Here's my sample java program that connects to the database and calls the
> stored procedure. It prints the dat it passes in and the date it gets back.
>
> ----- begin -----
> import java.io.* ;
> import java.sql.* ;
> import java.util.Properties ;
> import com.sybase.utils.* ;
>
> class Check
> {
> public static void main(String[] args)
> {
> try
> {
> Properties props = new Properties() ;
> props.put("user", "elapinsk") ;
> props.put("password", "nacmitg") ;
>
> Class.forName("com.sybase.jdbc.SybDriver") ;
> Connection connection = DriverManager.getConnection("jdbc:sybase:Tds:dubious:2025", props) ;
>
> CallableStatement statement = connection.prepareCall("{call rptDB..sp_check_jdbc_date(?)}") ;
> for(int month = 0 ; month < 12 ; month++)
> for(int date = 1 ; date < 31 ; date++)
> {
> Date in = new Date(96, month, date) ;
> statement.setDate(1, in) ;
> statement.registerOutParameter(1, Types.DATE) ;
> if(statement.execute()) System.err.println("results were not expected") ;
> Date out = statement.getDate(1) ;
> System.out.println("month=" + month + " date=" + date + " " + "in=" + in + " out=" + out) ;
> }
> }
> catch(Exception e)
> {
> e.printStackTrace(System.err) ;
> }
> }
> }
>
> ------ end ------