gaohan 发表于 2016-11-29 11:23:39

SQLite on BlackBerry 完美支持中文

  在SQLite on BlackBerry上,JDBC访问数据库,缺省是以UTF-8保存数据到数据库里面的,每个中文通常是3个字节保存到数据库上面的。
  例子代码参考:
  BlackBerry sample - SQLiteDemo。
  注意:在插入中文的时候,请使用Statement.bind指令,在我的测试中,可以很好的保存中文数据。读取的时候只需要使用ResultSet.getString()就可以了。
  而直接使用拼接好的sql insert语句插入数据,可能会有插入中文乱码问题。
  Statement statement = _db.createStatement("INSERT INTO Category VALUES(null, ?)");
statement.prepare();
statement.bind(1, name);
statement.execute();
statement.close();
  
参考:
1)sqlite
http://www.sqlite.org/download.html
  2)SQLite Expert Personal is freeware and does not have an expiration date.(可以识别UTF-8编码的中文数据)
  使用SQLite Expert Personal可以打开BlackBerry手机SD卡上的SQLite数据库,并且正常显示UTF-8编码的中文数据。This is just perfect for trouble shooting中文数据库。
  
http://www.sqliteexpert.com/download.html
  3)sqlite admin(不能识别UTF-8编码的中文数据)
http://sqliteadmin.orbmu2k.de/
  4)JDBC Driver for Windows(在eclipse 的perspective "Database Development" 中,使用SQL Scrapbook执行SQL语句可以正确创建表/插入/查看 中文数据)
http://www.zentus.com/sqlitejdbc/
http://www.xerial.org/trac/Xerial/wiki/SQLiteJDBC
页: [1]
查看完整版本: SQLite on BlackBerry 完美支持中文