Skip to content
프로젝트

소개

sql2o는 SQL 문 실행 결과를 객체로 쉽게 변환할 수 있는 작은 라이브러리입니다. ResultSet을 직접 다룰 필요가 없습니다. ORM과 비슷하지만 SQL 생성 기능은 제공하지 않습니다. 이름 있는 파라미터를 지원합니다.

데이터 및 분석

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
-1
in 1 month
-2

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

sql2o Github Actions Build Maven Central

Sql2o is a lightweight Java library designed to simplify database interaction. It automatically maps query results into POJO objects, providing an easy-to-use alternative to ORMs, without SQL generation capabilities.

Java versions

  • Sql2o 1.9.0 and newer is only compatible with Java 17 or later because it adds support for records.
  • If you use Java 11, sql2o 1.8.x is compatible.
  • If you are still on Java 8, use sql2o 1.6.x.

Announcements

Quick Start Example

Here's a basic example demonstrating how to use Sql2o to interact with a database:

import org.sql2o.*;

public class Main {
    public static void main(String[] args) {
        String url = "jdbc:h2:mem:test"; // Example using H2 in-memory database
        try (Sql2o sql2o = new Sql2o(url, "username", "password");
             Connection con = sql2o.open()) {
            
            con.createQuery("CREATE TABLE users (id INTEGER PRIMARY KEY, name VARCHAR(50))").executeUpdate();
            con.createQuery("INSERT INTO users (id, name) VALUES (:id, :name)")
                .addParameter("id", 1)
                .addParameter("name", "Alice")
                .executeUpdate();
            
            User user = con.createQuery("SELECT * FROM users WHERE id = :id")
                            .addParameter("id", 1)
                            .executeAndFetchFirst(User.class);
            
            System.out.println("User: " + user.name);
        }
    }
}

class User {
    public int id;
    public String name;
}

Coding Guidelines

When contributing to Sql2o, please follow these coding guidelines.

Wiki

For additional information, check out the Sql2o Wiki.

관련 프로젝트 살펴보기

불러오는 중…