1)下载sqlite jdbc驱动http://www.xerial.org/maven/repository/artifact/org/xerial/sqlite-jdbc/
2)将下载的驱动加入eclipse项目的built path中
3)示例代码:
2. C#连接sqlite
2.1 使用SQLITE.NET
SQLite.NET也是一个数据访问组件,其中的System.Data.SQLite 就好像是.NET自带的System.Data.SqlClient一样。里面包含了connection、command等数据访问的常用对象,只是他们前面都有一个前缀sqlite。
1)下载System.Data.SQLite,下载地址http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
2) 通过Add References引用SQLite ADO .NET安装目录的bin目录下的System.Data.SQLite.DLL。
3)创建表、读取数据等和Access或MS SQL没多大区别
</div>
2.2使用原生态的ADO.NET访问SQLite
</div>
SQLite.NET数据库连接字符串ConnectionString格式:
Basic(基本的)
Data Source=filename;Version=3;
Using UTF16(使用UTF16编码)
Data Source=filename;Version=3;UseUTF16Encoding=True;
With password(带密码的)
Data Source=filename;Version=3;Password=myPassword;
Using the pre 3.3x database format(使用3.3x前数据库格式)
Data Source=filename;Version=3;Legacy Format=True;
Read only connection(只读连接)
Data Source=filename;Version=3;Read Only=True;
With connection pooling(设置连接池)
Data Source=filename;Version=3;Pooling=False;Max Pool Size=100;
Using DateTime.Ticks as datetime format()
Data Source=filename;Version=3;DateTimeFormat=Ticks;
The default value is ISO8601 which activates the use of the ISO8601 datetime format
Store GUID as text(把Guid作为文本存储,默认是Binary)
Data Source=filename;Version=3;BinaryGUID=False;
如果把Guid作为文本存储需要更多的存储空间
Specify cache size(指定Cache大小)
Data Source=filename;Version=3;Cache Size=2000;