{"id":45243266,"url":"https://github.com/eisi05/sql-builder","last_synced_at":"2026-06-26T23:00:26.018Z","repository":{"id":254134644,"uuid":"845597559","full_name":"Eisi05/Sql-Builder","owner":"Eisi05","description":"This repository simplifies working with SQL in Java. ","archived":false,"fork":false,"pushed_at":"2026-06-26T20:28:59.000Z","size":86,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-06-26T21:05:39.576Z","etag":null,"topics":["database","java","mysql","sql","sql-builder","sql-parser"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Eisi05.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-21T14:53:01.000Z","updated_at":"2026-06-26T20:28:53.000Z","dependencies_parsed_at":null,"dependency_job_id":"031767bd-60d0-43db-9510-df504e7fa533","html_url":"https://github.com/Eisi05/Sql-Builder","commit_stats":null,"previous_names":["eisi05/sql-builder"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Eisi05/Sql-Builder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eisi05%2FSql-Builder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eisi05%2FSql-Builder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eisi05%2FSql-Builder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eisi05%2FSql-Builder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Eisi05","download_url":"https://codeload.github.com/Eisi05/Sql-Builder/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Eisi05%2FSql-Builder/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34835779,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-26T02:00:06.560Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","java","mysql","sql","sql-builder","sql-parser"],"created_at":"2026-02-20T21:33:17.872Z","updated_at":"2026-06-26T23:00:25.962Z","avatar_url":"https://github.com/Eisi05.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![](https://jitpack.io/v/Eisi05/Sql-Builder.svg)](https://jitpack.io/#Eisi05/Sql-Builder)\n\n# SQL Builder\n\nThis repository simplifies working with SQL.\n\nAll information are based on [W3Schools SQL documentation](https://www.w3schools.com/sql/default.asp).\n\n## Maven\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003ejitpack.io\u003c/id\u003e\n        \u003curl\u003ehttps://jitpack.io\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.Eisi05\u003c/groupId\u003e\n    \u003cartifactId\u003eSql-Builder\u003c/artifactId\u003e\n    \u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Gradle\n```gradle\ndependencyResolutionManagement {\n    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)\n    repositories {\n        mavenCentral()\n        maven { url 'https://jitpack.io' }\n    }\n}\n\ndependencies {\n    implementation 'com.github.Eisi05:Sql-Builder:1.1.0'\n}\n```\n\n## Creating a Database and Connecting to It\n### Available Database Types:\n- MySql\n-  Sql Server\n- Oracle\n- MsAccess\n\n```java\n// Example with MySql\n// Parameters: host, port, database, user, password\nDatabase database = new MySqlDatabase(\"localhost\", 3306, \"sql_builder\", \"root\", \"root\");\n\n// Connecting\nDatabase.SQLData data = database.connect();\n```\n\n## Creating Statements\n```java\n// Simple selection\n// This returns: SELECT * FROM TestTable WHERE ID = 5 AND NAME = 'TEST';\nFinalStatement selectStatement = data.select(\"*\").from(\"TestTable\").where(\"ID\").equal(5).and(\"NAME\").equal(\"TEST\");\n\n// Creating a new table\n// This returns: CREATE TABLE TestTable (Name VARCHAR(255) NOT NULL, ID BIGINT PRIMARY KEY);\nFinalStatement createStatement = data.createTable(\"TestTable\", \n        new TableColumn(\"ID\", SqlDataType.BIGINT).primaryKey(),\n        new TableColumn(\"Name\", SqlDataType.VARCHAR(255)).notNull());\n\n// Appending another statement\nFinalStatement finalStatement = createStatement.appendStatement(\n        data.insertInto(\"TestTable\", new InsertIntoStatement.InsertObject(\"ID\", 1)));\n\nfinalStatement.getQuery();\n// This will return:\n// CREATE TABLE TestTable (Name VARCHAR(255) NOT NULL, ID BIGINT PRIMARY KEY);\n// INSERT INTO TestTable (ID) VALUES (1);\n```\n\n## Executing a Statement\nOnly valid statements (FinalStatements) can be executed.\n\n1. **Execute**\n```java\nFinalStatement statement = ...;\n\n// ExceptionResult is similar to Optional, but also contains an Exception if an error occurs.\nExceptionResult\u003cBoolean\u003e result = statement.execute();\n\n// true if the first result is a ResultSet object; false if it is an update count or there are no results\nboolean success = result.result();\n```\n\n2. **Execute Update/Large Update**\n```java\nFinalStatement statement = ...;\n\nExceptionResult\u003cInteger\u003e result = statement.executeUpdate();\n\n// Returns either (1) the row count for SQL DML statements or (2) 0 for SQL statements that return nothing\nint rowCount = result.result();\n\n// For LargeUpdate, instead of an int, it returns a long\nExceptionResult\u003cLong\u003e result = statement.executeLargeUpdate();\n```\n\n3. **Execute Query**\n```java\nFinalStatement statement = ...;\n\nExceptionResult\u003cQueryResult\u003e result = statement.executeQuery();\n\n// A QueryResult works similar to a ResultSet\nQueryResult queryResult = result.result();\n\n// This can also be used with a SqlDataType (only works if only one column is selected!)\nExceptionResult\u003cLong\u003e result = statement.executeQuery(SqlDataType.BIGINT);\nlong queryResult = result.result();\n```\n   3.1. **getObjects(`\u003cdatatype\u003e`)**\n   ```java\n   // Returns a list of all the objects cast to the correct Java type\n   List\u003cLong\u003e ids = queryResult.getObjects(SqlDataType.BIGINT);\n   ```\n   3.2. **get(`\u003ckey\u003e`)/get(`\u003ccolumn\u003e`)**\n   ```java\n   // Returns a plain Object of that key/column\n   long id1 = queryResult.get(1);\n   long id2 = queryResult.get(\"ID\");\n\n   // This method can also be used with a SqlDataType\n   long id1 = queryResult.get(1, SqlDataType.BIGINT);\n   long id2 = queryResult.get(\"ID\", SqlDataType.BIGINT);\n   ```\n\n4. **Custom Statement**\n```java\nFinalStatement statement = ...;\n\n// This method takes a BiConsumer\u003cStatement, String\u003e, where Statement is a java.sql.Statement and String is the query,\n// which can also be obtained with statement.getQuery();\nstatement.createStatement((stmt, query) -\u003e {\n    stmt.executeUpdate(query);\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feisi05%2Fsql-builder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feisi05%2Fsql-builder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feisi05%2Fsql-builder/lists"}