Register / Login
Win a copy of
Mesos in Action
this week in the
JDBC and Relational Databases
Postgres JDBC encoding...
posted 4 years ago
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
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.
Replacing a word in a text file
Uploading excel sheet to Database
Regarding reading a file in a jsp
to read lines inside brackets
Error printing out from a read in file.