E
E
Evgeny Popov2014-09-21 08:19:10
Java
Evgeny Popov, 2014-09-21 08:19:10

How to solve the problem with encoding in a java project when it is in utf, and the data is in win1251?

The problem appears only if you run the project in linux (ubutu, netbeans, if it matters).
The firebird database is launched in windows, if the project is also launched in windows, then the data from the database is displayed "correctly", if in linux, then - "crazy".
In the jdbc settings "everywhere" is utf8 (changing the settings to win1251 does not affect the result), the data in the win1251 database.
If the application in netbeans (with the same settings) is launched in windows, everything is correct.
Condition:
You cannot change the encoding in the database.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
E
Evgeny Popov, 2014-11-13
@Kaaboeld

jdbc.databaseurl=jdbc:firebirdsql:127.0.0.1/0000:D:/base/base.fdb?encoding=utf8&useUnicode=true&characterEncoding=utf8

127.0.0.1 - ip сервера
0000 - порт
D:/base/base.fdb - путь до базы(сервер на windows)

So I tried many different options for specifying the encoding and not only in this config, and accidentally stumbled upon the encoding parameter , and that's it, it worked by setting it to utf8 .
The most interesting thing is that this solution works when starting the project under linux (ubuntu), but if the project is started with this parameter on windows, then exactly the encoding problem that I tried to overcome and therefore the parameters after the "path to the base" begins to appear there you have to delete it there, and put it back under linux.

B
bvp, 2014-11-12
@bvp

Is it still relevant or not..
For normal display of data from Firebird, I use Properties for connection parameters

String conString = "jdbc:firebirdsql:192.168.0.5:bsklad";
...
paramConnection = new Properties();
paramConnection.setProperty("user", "beginner");
paramConnection.setProperty("password", "mayby");
paramConnection.setProperty("encoding", "WIN1251");
...
Class.forName("org.firebirdsql.jdbc.FBDriver");
connection = DriverManager.getConnection(conString, paramConnection);

Where the base is spinning does not matter! The encoding of the base itself matters.

E
Eugene, 2014-09-25
@zolt85

I would look into the Locale settings on startup on Windows and on Linux.

V
Vasily, 2014-10-05
@Applez

Convert upon receipt.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question