2024年5月28日发(作者:)

在Java中使用SQLite的教程

时间:2009-12-15 sqlite 林轩

我一直想写一个在Java中使用SQLite的例子,但是很长时间都找不到一个真正合适

的, 现在我终于找到了,我希望它可以帮助那些像我一样的Java新手走出困惑.

测试环境

Intel x86 Laptop

Windows XP SP2

Java2 JDK 1.5 Update 8

Netbeans IDE 5.0 import .*;

import ;

/**

* Very Basic SQLite Database Example

* @author Brandon Tanner

*/

public class SQLiteTest {

public static void main(String[] args) {

try {

// The SQLite (3.3.8) Database File

// This database has one table (pmp_countries) with 3 columns (country_id,

country_code, country_name)

// It has like 237 records of all the countries I could think of.

String fileName = "c:/";

// Driver to Use

//

e("");

/sqlitejdbc/

// Create Connection Object to SQLite Database

// If you want to only create a database in memory, exclude the +fileName

Connection conn = nection("jdbc:sqlite:"+fileName);