sqlite与COM
Dim Content,DB,DBPath,Strsql
Content = Request.Form("Content")
Set DB = Server.CreateObject("newObjects.sqlite3.dbutf8")
DBPath = Server.MapPath(".") & "\spring.db"
If DB.Open(DBPath) Then
Strsql = "Update SH_Spring Set Content=? Where ID=1"
Dim a(0)
a(0) = Content
DB.AExecute Strsql,a
DB.Close
Else
Response.Write "连接数据库时发生错误: "& db.LastError
End If
Set DB = Nothing
Content = Request.Form("Content")
Set DB = Server.CreateObject("newObjects.sqlite3.dbutf8")
DBPath = Server.MapPath(".") & "\spring.db"
If DB.Open(DBPath) Then
Else
End If
Set DB = Nothing
sqlite与Java
sqlite源代码是C,而且官方网站上只提供了C和Tcl语言的接口。为了应用Java接口,要采用第三方的接口驱动程序,可在http://www.ch-werner.de/javasqlite中找到这个Java接口程序。这个接口提供了两种连接sqlite的方式:一是直接用JNI技术调用sqlite的C语言接口,这种方式要求开发人员要对sqlite本身的API也有一定的了解。在第二种方式中,接口程序实现了Java标准规范的JDBC接口,这样开发人员只要对JDBC有了解就可以了。
下载到新的(javasqlite-20080401-win32.zip),解开注意看目录名字,是j2sdk1.4.2_03,说明此版本应在jdk1.4.2版本以上,找到安装的jdk目录,把这个包中的jre\bin\sqlite_jni.dll和jre\lib\ext\sqlite.jar分别放在jdk目录的jre对应目录名称下(我在测试jsp页面中,总是报NoClassFound错误,这2个文件都需要放在jre目录下的,JNI技术只用前面的dll即可,注意用jdbc链接方式请也要放dll文件的。)
开始在Tomcat中跑个测试程序了,建一个test.jsp
String dbUrl = "jdbc:sqlite:/"+application.getRealPath("pay_sh").replace("\\","/")+"/IPTV_SH.db"; (1)
Class.forName("sqlite.JDBCDriver"); (2)
Connection conn = DriverManager.getConnection(dbUrl);
Class.forName("sqlite.JDBCDriver"); (2)
Connection conn = DriverManager.getConnection(dbUrl);
if (conn != null){
String sql = "Select UserId from UserFree where userid='99900015'";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
while (rs.next()){
out.println(rs.getString("userid"));
}
}
}
rs.close();
stmt.close();
conn.close();
jdbc:sqlite://dirA/dirB/dbfile
jdbc:sqlite:/DRIVE:/dirA/dirB/dbfile
jdbc:sqlite:///COMPUTERNAME/shareA/dirB/dbfile
jdbc:sqlite:/DRIVE:/dirA/dirB/dbfile
jdbc:sqlite:///COMPUTERNAME/shareA/dirB/dbfile
(2)这里因为jar包不同,可能写法不同,有的是"org.sqlite.xxx"