java读取db文件,使用java读取SQLite db文件

本文介绍如何使用Java读取SQLite数据库文件。通过引入David Crawshaw的Java JDBC驱动,将JAR添加到类路径,然后使用java.sql.*进行操作。示例代码创建了一个数据库连接,创建表格,插入数据并从表格中读取数据,展示了基本的数据库交互流程。
摘要由CSDN通过智能技术生成

I want to read a SQLite db file using Java. Will you please tell me how to read it?

解决方案

check out website of David Crawshaw who has a Java JDBC driver for SQLite. Just add his JAR file to your classpath and import java.sql.*

His test app will create a database file, send some SQL commands to create a table, store some data in the table, and read it back and display on console. It will create the test.db file in the root directory of the project.

public class Test {

public static void main(String[] args) throws Exception {

Class.forName("org.sqlite.JDBC");

Connection conn = DriverManager.getConnection("jdbc:sqlite:test.db");

Statement stat = conn.createStatement();

stat.executeUpdate("drop table if exists people;");

stat.executeUpdate("create table people (name, occu

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值