Results 1 to 2 of 2
  1. #1
    Join Date
    May 2008
    Posts
    3

    Unanswered: Pass a date to a java function in SqlAnywhere 10

    NewsGroup: ianywhere.public.general
    Date: May 23,2008 02:11 am
    Created by: Bert Belaen
    Topic: Passing date parameters to a java-method
    Attachments: testJavaInSA10.java

    We're testing SqlAnywhere 10. We want to upgrade from
    version 7.
    We've implemented a lot of functionality in Java in the
    database.
    Now I've encountered a problem when i want to pass a date to a java-method. I created a little test-class, for the
    source-code, see the attachment (provided with a .txt extension instead of .java because .java is not allowed).
    We compiled it with JDK 1.1.8, and uploaded it to the database. Then we created a wrapper-function, see below :

    create function fdb_getStringDate(in testDate date) returns
    char(200) external name
    'testJavaInSA10.getStringDate(Ljava/sql/Date; )Ljava/lang/String;
    ' language java;

    The only thing this function do is accept a date-parameter,
    and return the string-value. When we call this function we
    receive a 'java.text;ParseException : Unparseable date
    "2003-12-31"'
    SQLCODE=-91, ODBC 3 STATE = "HY000"

    For the other functions I also created wrapper-functions and this works just fine. It seems that the java-function has a problem with converting a Sybase-date to a java.sql.Date class, which is according to the documentation the right mapping-type.

    Any suggestion or help is welcome.
    Attached Files Attached Files

  2. #2
    Join Date
    May 2008
    Posts
    2
    Hi,

    Well, first of all... JDK 1.1.8 ?? why?

    as to your question, you might try converting the returned date into a string and then via substring build up the date into the desired format.

    Either that, or you might want to try to convert it into a different format in the database before you return it.
    select convert(datetime, <datefield>,<format>)
    an example of sybase formats can be found here:

    http://www.comsci.us/sybase/date_fmt.html
    -vertho


    Quote Originally Posted by BertBel
    NewsGroup: ianywhere.public.general
    Date: May 23,2008 02:11 am
    Created by: Bert Belaen
    Topic: Passing date parameters to a java-method
    Attachments: testJavaInSA10.java

    We're testing SqlAnywhere 10. We want to upgrade from
    version 7.
    We've implemented a lot of functionality in Java in the
    database.
    Now I've encountered a problem when i want to pass a date to a java-method. I created a little test-class, for the
    source-code, see the attachment (provided with a .txt extension instead of .java because .java is not allowed).
    We compiled it with JDK 1.1.8, and uploaded it to the database. Then we created a wrapper-function, see below :

    create function fdb_getStringDate(in testDate date) returns
    char(200) external name
    'testJavaInSA10.getStringDate(Ljava/sql/Date; )Ljava/lang/String;
    ' language java;

    The only thing this function do is accept a date-parameter,
    and return the string-value. When we call this function we
    receive a 'java.text;ParseException : Unparseable date
    "2003-12-31"'
    SQLCODE=-91, ODBC 3 STATE = "HY000"

    For the other functions I also created wrapper-functions and this works just fine. It seems that the java-function has a problem with converting a Sybase-date to a java.sql.Date class, which is according to the documentation the right mapping-type.

    Any suggestion or help is welcome.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •