File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Java SE 8 for the Really Impatient
this week in the
Postgres JDBC encoding...
Joined: May 19, 2012
May 19, 2012 10:06:14
Hello! Can somebody help me to resolve the following issue? Thanks.
I have the text file. Its encoding is ISO-8859-1. How did I know this? I opened the file in my Firefox and looked at the menu Web developer-> Character Encoding.
In Firefox I see the following
in the file: "aaaÃ©bbb".
I read this file in Java program using the following code:
FileInputStream fstream = new FileInputStream(fileName); DataInputStream in = new DataInputStream(fstream); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String strLine; strLine = br.readLine();
When I print strLine in my Eclipse console I see this string: "aaaГ©bbb". Eclipse console is configured to show in Cp1251 encoding.
I have Postgres 9.0 database and the same string in it. When I select it via pgAdmin I see the same as in Eclipse console.
Now I need to read this string from file and to select from DB via
using this string in WHERE clause.
But my select returns zero result.
When I change my sql from "WHERE field='"+strLine+"'" to "WHERE field LIKE 'aaa__bbb'" result is fine.
How can I use my string from file for correct select via JDBC? Thanks for any help.
I agree. Here's the link:
subject: Postgres JDBC encoding...
Error printing out from a read in file.
to read lines inside brackets
Replacing a word in a text file
Regarding reading a file in a jsp
Uploading excel sheet to Database
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014