wood burning stoves 2.0*
The moose likes JDBC and the fly likes junk characters for byte charset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "junk characters for byte charset" Watch "junk characters for byte charset" New topic
Author

junk characters for byte charset

Nayan Khare
Greenhorn

Joined: Sep 26, 2003
Posts: 2
Hi all,
Serious Urgent problem:
i am working on a Japanese OS
i have got 2 info objects, and 2 statement objects, i am opening a connection with Properties info1:
info1.put("user", "...");
info1.put("password", "...");
Connection con1, Statement stmt1, and ResultSet rs1. After executing query with stmt1, I am opening a new connection with Properties info2:
info2.put("user", "...");
info2.put("password", "...");
info2.put("charSet", "ISO8859_1");
Connection con2, Statement stmt2, and ResultSet rs2. I am performing a close on con2,stmt2,rs2.
I am doing:
rs1=stmt1.executeQuery("SELECT...");
The problem is that rs1.getString(1) isn't printing the same japanese characters anymore, instead giving garbage chracters.
The sample code is:
Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Properties info = new Properties();
info.put("user", "...");
info.put("password", "....");

Connection con1 = DriverManager.getConnection("jdbc dbc:...", info);
Statement stmt1 = con1.createStatement();

ResultSet rs1 = stmt1.executeQuery("SELECT FIELD2 FROM FOO");
if (rs1.next())
{
System.out.println("First try with connection1: " + rs1.getString(1));
}
//Class.forName ("sun.jdbc.odbc.JdbcOdbcDriver");
Properties info2 = new Properties();
info2.put("user", "...");
info2.put("password", "d...");
info2.put("charSet", "ISO8859_1");
Connection con2 = DriverManager.getConnection("jdbc dbc:HARIT", info2);

Statement stmt2 = con2.createStatement();

ResultSet rs2 = stmt2.executeQuery("SELECT FIELD2 FROM FOO WHERE FIELD1 = 2");
if (rs2.next())
{
System.out.println(rs2.getString(1));
}
rs2.close();
stmt2.close();
con2.close();
rs1 = stmt1.executeQuery("SELECT FIELD2 FROM FOO");
if (rs1.next())
{
System.out.println("Second try with connection1: " + rs1.getString(1));
}
rs1.close();
stmt1.close();
con1.close();
I want to know is this a JDBC techinical Spec problem or something else. nayan_khare@yahoo.com
Dave Bender
Greenhorn

Joined: Oct 16, 2003
Posts: 3
This may be wrong, but you set the charSet property to be "ISO8859_1". Shouldn't it be "ISO_8859_1" or "ISO-8859-1" with a separator between the ISO and the start of the numbers?
Nayan Khare
Greenhorn

Joined: Sep 26, 2003
Posts: 2
I have tried with the charSet property set to "ISO_8859_1" and "ISO-8859-1" but it doesn't work, I think this is some kind of internal problem.
Thanks for the reply, hoping u would give a solution.
Nayan Khare
nayan_khare@yahoo.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: junk characters for byte charset
 
Similar Threads
two dropdown menus
Exception while using JNDI resources
ResultSet Thru ResultSet
I M NOT ABLE TO DEFINE VARIABLES IN JSP.
Invalid cursor state