Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    13

    Unanswered: Is there limitation of text size about text datatype?

    I try to insert a record to sybase, the datatype of column is TEXT, using

    preparedstatement.setString(1, text);

    But I get the exception: com.sybase.jdbc3.jdbc.SybSQLException: Implicit conversion from datatype 'TEXT' to 'VARCHAR' is not allowed. Use the CONVERT function to run this query.

    Is there any limitation of text size for TEXT datatype?
    Visit my homepage at http://www.carfield.com.hk

  2. #2
    Join Date
    Dec 2005
    Posts
    39
    i think the problem doesn't seems related to text size but on how you're inserting the data. the error message seem to say that you're trying to add text data into varchar. If this is the case then you might have to use

    select varchar-field = convert(varchar(n), text-field)

    since varchar (as of 12.5) can store a maximum of 16K depending on page size while text can store a maximum of 2GB, so you can't directly store text into varchar.

  3. #3
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    13
    Thx, but the datatype is TEXT but not VARCHAR, that is what I don't understand....
    Visit my homepage at http://www.carfield.com.hk

  4. #4
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    dude,

    setString is used only for Character data and hence the conversion. Check out the JDBC programmers manual for TEXT.

  5. #5
    Join Date
    Sep 2002
    Location
    Hong Kong
    Posts
    13
    Thx for the information, according to the manual:

    66 jConnect for JDBC
    If your data server is Adaptive Server 12.5 or later or Adaptive Server
    Anywhere version 6.0 or later, use the standard JDBC form to send text data:
    PreparedStatement.setAsciiStream(int paramIndex,
    InputStream text, int length)
    or
    PreparedStatement.setUnicodeStream(int paramIndex,
    InputStream text, int length)
    or
    PreparedStatement.setCharacterStream(int paramIndex,
    Reader reader, int length)

    However, if our application need to support both 12.5 later or before, does it still apply??
    Visit my homepage at http://www.carfield.com.hk

  6. #6
    Join Date
    Feb 2002
    Location
    Willy is on vacation
    Posts
    1,208
    not sure. I would presume, AsciiStream should work for both. I just stick to jTDS these days.

Posting Permissions

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