-
Notifications
You must be signed in to change notification settings - Fork 229
Improved README with examples and updated compatibility #378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,53 @@ | ||
| # sql2o [](https://github.com/aaberg/sql2o/actions) [](https://search.maven.org/search?q=g:org.sql2o%20a:sql2o) | ||
| # sql2o   | ||
|
|
||
| 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. | ||
|
|
||
| Sql2o is a small java library, with the purpose of making database interaction easy. | ||
| When fetching data from the database, the ResultSet will automatically be filled into your POJO objects. | ||
| Kind of like an ORM, but without the SQL generation capabilities. | ||
| Sql2o requires at Java 7 or 8 to run. Java versions past 8 may work, but is currently not supported. | ||
| Sql2o is compatible with **Java 8 and later versions**, including Java 11 and 17. | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wow, that old description, saying that it isn't compatible with Java 8 or newer, is very misleading. Thanks for updating! |
||
|
|
||
| # Announcements | ||
| *2024-03-12* | [Sql2o 1.7.0 was released](https://github.com/aaberg/sql2o/discussions/365) | ||
| ## Announcements | ||
|
|
||
| - *2024-03-12* | [Sql2o 1.7.0 was released](https://github.com/aaberg/sql2o/discussions/365) | ||
|
|
||
| # Examples | ||
| ## Quick Start Example | ||
|
|
||
| Check out the [sql2o website](http://www.sql2o.org) for examples. | ||
| Here's a basic example demonstrating how to use Sql2o to interact with a database: | ||
|
|
||
| # Coding guidelines. | ||
| ```java | ||
| 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](https://github.com/aaberg/sql2o/wiki/Coding-guidelines). | ||
|
|
||
|
|
||
| ## Wiki | ||
|
|
||
| For additional information, check out the [Sql2o Wiki](https://github.com/aaberg/sql2o/wiki). | ||
|
|
||
| When hacking sql2o, please follow [these coding guidelines](https://github.com/aaberg/sql2o/wiki/Coding-guidelines). | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the github actions and maven labels?