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
相关文档:
SQLite用触发器来替代外键约束 CREATE TABLE [Category] (
[Pkid] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
[CategoryName] NVARCHAR(32) NOT NULL,
[CategoryGuid] char(36) UNIQUE NOT NULL,
[CategoryDesc] nvarchar(256) NULL
) C ......
我老婆工作要管理好多的excel表格比较的麻烦,于是想着帮忙写个软件让她方便点
其实我winform软件还没有写过呢,以前写的都是web的
因为写的软件就是她自己用用我想应该不需要用什么大的数据库的,所以我最先想到用access数据库挺方便的文件复制就可以了
可是我没有office access啊,不过我记得电脑上好像有access数据库 ......
先记下来:
FileOutputStream outputStream = openFileOutput("mydb", 0);
InputStream inputStream = response.getEntity().getContent();
byte[] data = new byte[bufferSize];
for (int i = inputStream.read(data); i > 0; i = inputStream
.read(data)) {
& ......
1:从sqlite的官网上下载源码 http://www.sqlite.org/download.html
2:打开vs2008工程新建一个空的dll工程。
3:把sqlite3.h,sqlite3.cpp,sqlite3.def分别加入到head file 和source file下。
4:编译程序。 这时只能得到sqlite3.dll文件。
5:打开vs2008自带的命令行: 切到sqlite3.def所在的目录。
6:运行 ......
本文以数据库中的数据表UserInfo为实例展示数据库表的创建及数据记录的录入。
#!/bin/sh
#variables definition
#database location
db=/conf/db
#
#create table userInfo
#name: User name
#passwd: Password
#Privilege: User privilege -- Administrator:0 Operator:1
#
echo "create table UserInfo(n ......