ORMLiteORM持久层框架

联合创作 · 2023-09-30

ORMLite是一个轻量级的Java对象关系映射持久层框架。支持包括 MySQL、Postgres、Microsoft SQL Server、H2、Derby、HSQLDB和Sqlite等在内的数据库。提供灵活的QueryBuilder来构建复杂的数据查询。强大的抽象DAO类,只需5行代码便能够自动生成SQL来创建和删除数据库表格。

示例代码:

public class AccountApp {

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

        // this uses h2 by default but change to match your database

        String databaseUrl = "jdbc:h2:mem:account";

        // create a connection source to our database

        ConnectionSource connectionSource = new JdbcConnectionSource(databaseUrl);

        // instantiate the dao

        AccountDaoImpl accountDao = new AccountDaoImpl(connectionSource);

        // if you need to create the 'accounts' table make this call

        TableUtils.createTable(connectionSource, Account.class);

浏览 4
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报