Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Bad character encoding when ResultSet is CONCUR_UPDATABLE

843859Feb 11 2007
Hi,

I have one problem with encoding of texts loaded from database (slovak, czech).

My environment first:

MS SQL Server 2000, standard JDBC drivers from Microsoft
DB table encoded in windows-1250
SAP WAS application server on UNIX, file_encoding property = iso-8859-1

Here is part of JSP (using only for tests ;-)):
<%@ page language="java" contentType="text/html;charset=iso-8859-2"%>
<% request.setCharacterEncoding("iso-8859-2"); %>
...
<%

  try {
     
    // ... getting connection   
   
    java.sql.Statement stmt = conn.createStatement ( 
      ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE ); 
    
    String q = "SELECT col FROM table where id='1'";
    
    java.sql.ResultSet result = stat.executeQuery(q);

    if ( result.next() )
      out.write( result.getString(1) );
  
  }
  catch ( SQLException sqle ) 
  
  // ...
  
%>
In first two lines I've tried utf-8, iso-8859-1, windows-1250 (also with pageEncoding directive) and I've check browser encoding setting in every case.

Then I've tried tens of combination in this way:
out.write( new String (result.getString(1).getBytes("windows-1250"), "iso-8859-1"));
Nothing from this helps.


And now, for me the most interesting part. When I change line with statement creation from:
stmt = conn.createStatement ( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
to:
stmt = conn.createStatement ( ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
diacritic works... (for every setting {iso-8859-2, utf-8, windows-1250} )

I've tried to load data from Oracle database using thin driver -> no problem (ResultSet.CONCUR_UPDATABLE works)
Also, I've run similar program as standalone application in console and MS SQL 2000 -> no problem, again
.
Can you give me advice, how to solve this problem? Thanks for any answer.

Regards,
djuri
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 11 2007
Added on Feb 11 2007
0 comments
443 views