Bug #7033 PreparedStatement doesn't show BIG5 characters correctly
Submitted: 6 Dec 2004 10:36 Modified: 20 Dec 2004 18:11
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.0.16 OS:Microsoft Windows (Windows 2000 Pro)
Assigned to: Mark Matthews CPU Architecture:Any

[6 Dec 2004 10:36] [ name withheld ]
Description:
When I print the table columns which contains double byte characters using "PreparedStatement", it just shows number of question marks (??).
However, when I change to "Statement", the double-byte characters showing fine.

Moreover, Connector/J version of 3.0.9-stable has no such problem.

Regards,
Kevin.

How to repeat:
<HTML>

<%@ page language="java" import="java.sql.*" contentType="text/html;charset=UTF-8"%>
<%
  String sSQL = "select 1 as \"\u5957 \u9910\" from dual";

  Class.forName("com.mysql.jdbc.Driver");
  Connection cn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root");
  Statement stmt = cn.createStatement();
  PreparedStatement ps = cn.prepareStatement(sSQL);

  ResultSet rs = ps.executeQuery();

  //use "Statement" instead of "PreparedStatement", characters show correctly.
  //ResultSet rs = stmt.executeQuery(sSQL);

  //prints (??)
  out.println(rs.getMetaData().getColumnName(1));
  
  rs.close();
  rs = null;
  
  stmt.close();
  stmt = null;
  
  ps.close();
  ps = null;
  
  cn.close();
  cn = null;

%>
</BODY>
</HTML>
[15 Dec 2004 22:17] Mark Matthews
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.mysql.com/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Additional info:

You need to specify what server version you are using, DDL for your table(s) and any non-standard configuration options (i.e. --default-charset) that your server uses for us to be able to reproduce/fix this.
[19 Dec 2004 3:15] [ name withheld ]
Thanks, Mark.

Here is the system configuration:

OS: Windows 2000 Pro
Web Server: jakarta-tomcat-4.1.18
Connnector/J Version: 3.0.16
My SQL Version: 4.0.20a
my.ini:
[mysqld]
basedir=C:/MYSQL
datadir=C:/MYSQL/data
default-character-set=big5

[WinMySQLadmin]
Server=C:/MYSQL/bin/mysqld-opt.exe

How to repeat:

<HTML>
<%@ page language="java" import="java.sql.*"
contentType="text/html;charset=UTF-8"%>
<%
  Class.forName("com.mysql.jdbc.Driver");
  Connection cn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root");
  Statement stmt = cn.createStatement();
  String sSQL = "select 1 as \"\u5957 \u9910\" from demo";
  PreparedStatement ps = cn.prepareStatement(sSQL);

  stmt.executeUpdate("create temporary table demo (x varchar(1))");
  stmt.executeUpdate("insert into demo values('1')");
  
  //use "Statement" instead of "PreparedStatement", characters show correctly.
  //ResultSet rs = stmt.executeQuery(sSQL);
  ResultSet rs = ps.executeQuery();

  //prints (??)
  out.println(rs.getMetaData().getColumnName(1));
  
  rs.close();
  rs = null;
  
  stmt.close();
  stmt = null;
  
  ps.close();
  ps = null;
  
  cn.close();
  cn = null;
%>
</HTML>
[20 Dec 2004 18:11] Mark Matthews
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html
[28 Jan 2005 6:50] [ name withheld ]
Hi,

Just downloaded and tried on the lastest versions:

mysql-connector-java-3.1.6-bin.jar
mysql-connector-java-3.2.0-alpha-bin.jar

Use the sample code of "How to repeat". This time, the output not showing the questoin marks (??), but some unreadable characters.

Regards,
Kevin.