If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > MySQL + JDBC + "latin1" METADATA ????

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-02-05, 12:15
spybreaker spybreaker is offline
Registered User
 
Join Date: Feb 2005
Posts: 1
Exclamation MySQL + JDBC + "latin1" METADATA ????

Hi everyone,

I'm connecting to a MySQL 4.1.7 DB through the "com.mysql.jdbc.Driver" MySQL JDBC 3.1.6 Driver in a webapp running on Tomcat 5.

Everything is working fine, I am able to execute queries and parse the resultsets being returned by these queries.

My problem is just about the METADATA retrieval... I use "latin1" as default character set for all of my DBs, Tables, Server, Conns, etc. That way I am able to store and retrieve characters like "ηγ" onto my tables. When I use latin characters onto the METADATA (like "field enum('ηγ')" in a CREATE TABLE definition), the characters are also being stored correctly. Until now, everything was fine. However, when I try to retrieve the METADATA created with latin chars (using some command like "SHOW COLUMNS LIKE 'field' "), they come replaced by "??"... How could I retrieve this METADATA information with the right latin characters instead of the bizzarre "??" ???

Below is all the information about the Table Creation and the JSP Code that retrieve incorrect the METADATA:

CREATE TABLE `tbl_Test` (
`tp_test` enum('ABC','CDE','ηγι') NOT NULL default 'ABC',
) ENGINE=InnoDB DEFAULT CHARSET=latin1

PS: Table created through the SQLyog Client

<%@page import="java.sql.*"%>
<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%response.setContentType("text/html; charset=ISO-8859-1");%>
<%
String driverClassName = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://SERVERNAME/DBNAME?user=me&password=secret&useUnicode=true&cha racterEncoding=ISO8859_1";
String query = "SHOW COLUMNS FROM `tbl_Test` LIKE '%tp_test%';";
String vals = null;

Class.forName(driverClassName).newInstance();
Connection con = DriverManager.getConnection(url);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery( query );

if( rs.next() ) {
vals = rs.getString(2);
}
%>
<%=valores%>



Here is what I get when I execute the above JSP:
enum('ABC','CDE','??????')
In other words: NONE of the latin characters were correctly retrieved...


Here is some other info about my MySQL server that may be usefull:
mysql> SHOW VARIABLES LIKE '%character%';
+--------------------------+----------------------------------+
| Variable_name | Value |
+--------------------------+----------------------------------+
| character_set_client | latin1 |
| character_set_connection | latin1 |
| character_set_database | latin1 |
| character_set_results | latin1 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/share/mysql/charsets/ |
+--------------------------+----------------------------------+
7 rows in set (0.02 sec)

PS: See the above "character_set_system | utf8" ??? Changing this to "latin1" will solve my problems?? If so, how can I set this value??

I'd really appreciate any help that could at least point me to the right directions.

Tnx in advance,
Anderson SPYBREAKER!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On