• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

junk characters for byte charset

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic