1

I'm working on a class assignment. I have to store data in sqlite and data is in Cyrillic. When I use 3rd party software to browse sqlite database i see text in proper Cyrillic. But when I retrieve data with java I get ?????? (question marks).

I use sqlite-jdbc-3.7.2 wrapper.

Lord Zed
  • 750
  • 7
  • 28

1 Answers1

0

Try this way:

SQLiteDataSource ds = new SQLiteDataSource();
ds.setEncoding("UTF_8");
Connection conn = ds.getConnection();
  • here is how i connect to sqlite db: `Class.forName("org.sqlite.JDBC"); conn = DriverManager.getConnection("jdbc:sqlite:test.db"); stm = conn.createStatement();` how do i implement your solution in it? – Lord Zed Apr 23 '14 at 07:49
  • `Class.forName(org.sqlite.JDBC.class.getCanonicalName()); String url = "jdbc:sqlite:test.db"; SQLiteConfig config = new SQLiteConfig(); config.setEncoding(SQLiteConfig.Encoding.UTF8); Connection conn = DriverManager.getConnection(url, config.toProperties());` – Boris Nebosenko Apr 23 '14 at 13:03
  • Ok I've found what was the problem and it was not java sqlite jdbc encoding issue. I was eclipse. I've found solution here: [http://stackoverflow.com/a/21434836/2470538](http://stackoverflow.com/a/21434836/2470538) – Lord Zed Apr 24 '14 at 21:28