Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Posts
    2

    Question Unanswered: jdbc text codeset conversion

    how can i setup automatic codeset conversion of text type column?
    IFX_CODESETLOB parameter in connection url don't work (blob not found). i tried set this parameter to 0 or some value ...

  2. #2
    Join Date
    Oct 2003
    Posts
    29
    Not sure why you are getting blob not found error .
    IFX_CODESETLOB seems to work only with the methods from
    java.sql.PreparedStatement interface
    i.e. PreparedStatement::setAsciiStream()
    and PreparedStatement::getAsciiStream()
    Make sure that you have set CLIENT_LOCALE and DB_LOCALE property to correct value.

    If you are using methods from jaca.sql.Clob interface ,
    I think you need to convert using JDK methods as shown
    in Informix JDBC manual
    http://publibfi.boulder.ibm.com/epubs/pdf/ct1utna.pdf
    page 6-22.

    Here is a code sample which inserts and fetches from a
    clob column

    Your connection url will look something like this
    String url =".........;CLIENT_LOCALE=en_US.CP1252;IFX_CODESET LOB=1;DB_LOCALE=en_US.8859-1;......";


    public static void insertStuff(Connection conn) throws SQLException , IOException
    {

    try
    {
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("drop table tab1");
    stmt.close();
    }
    catch (SQLException e)
    {
    System.out.println(e);
    }

    try
    {
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("create table tab1 (col1 clob)");
    }
    catch (SQLException e)
    {

    System.out.println(e);
    }

    PreparedStatement pstmt = conn.prepareStatement("insert into tab1 (col1) values (?)");
    File f = new File("c:\\sample.txt");
    long size = f.length();
    InputStream is = new FileInputStream(f);
    // this will codeset convert text from CLIENT_LOCALE codeset
    // to DB_LOCALE codeset
    pstmt.setAsciiStream(1,is,(int)size);
    pstmt.execute();
    pstmt.close();
    }


    public static void getStuff(Connection conn) throws SQLException , IOException
    {
    PreparedStatement pstmt = conn.prepareStatement("select (col1) from tab1");
    ResultSet rs = pstmt.executeQuery();

    while(rs.next())
    {
    // this will codeset convert text from DB_LOCALE codeset
    // to CLIENT_LOCALE codeset
    InputStream is = rs.getAsciiStream(1);
    byte[] recv = new byte[is.available()];
    is.read(recv);
    is.close();
    }

    }

  3. #3
    Join Date
    Nov 2003
    Posts
    2
    thank you for you reply.
    i tried use this with com.borland.dx.sql.dataset classes in borland JBuilder9.

  4. #4
    Join Date
    Nov 2003
    Posts
    3
    I made a mistake in earlier post
    IFX_CODESETLOB needs to be set to zero !
    Setting it to one does not make much of sense

Posting Permissions

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