N
N
Nikolay Baranenko2017-03-11 23:55:51
Java
Nikolay Baranenko, 2017-03-11 23:55:51

How to solve the problem with Cyrillic in FireBird?

Hello.
created a database and a FireBird 3 table with a field in Cyrillic

SQL> CREATE DATABASE 'D:\databases\Firebird\data\example.fdb' USER 'SYS' PASSWORD 'пароль' DEFAULT CHARACTER SET WIN1251;
SQL> create table customers(id int not null,name varchar(50));
SQL> insert into customers values (1,'first');
SQL> insert into customers values (2,'второй');
SQL> commit;
SQL> select * from customers;

          ID NAME
============ ==================================================
           1 first
           2 второй

Wrote a client in Java with encoding WIN1251 result
Properties props = new Properties();
        props.setProperty("user", "sys");
        props.setProperty("password", "пароль");
        props.setProperty("encoding", "WIN1251");
        String connection_string=connection_string="jdbc:firebirdsql:192.168.10.41/3050:D:\\databases\\Firebird\\data\\example.fdb";
        boolean st = false;
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        String Connection_Status = "";
        String value;
        Integer count_values;

        try {
            Class.forName("org.firebirdsql.jdbc.FBDriver");
            Connection connection = DriverManager.getConnection(connection_string, props);
            connection.close();
            Connection_Status = "Подключение к БД " + connection_string + " прошло успешно.";

            try {

                //loading drivers for mysql
                Class.forName("org.firebirdsql.jdbc.FBDriver");

                //creating connection with the database
                con = DriverManager.getConnection
                        (connection_string, props);
                ps = con.prepareStatement
                        (Text_Script);
                //ps.setString(1, uname);
                //ps.setString(2, pass);
                rs = ps.executeQuery();
                //st = rs.next();
                value = "";
                count_values = 0;
                // iterate through the java resultset
                while (rs.next()) {
                    count_values = count_values + 1;
                    value = value + rs.getString("ID") + "; ";
                    value = value + rs.getString("name") +"; ";
}

but as a result I get abracadabra instead of Cyrillic
1; first; 2; ўв®а®©;
How to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
aol-nnov, 2017-03-12
@drno-reg

I have strange memories that in cmd.exe the default encoding is 866, not 1251. but I haven't worked with venda for a long time.
I would make a csv text file that would be guaranteed to be in 1251 and would drive it into the database. then I would have checked.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question