-
Couldn't load subscription status.
- Fork 1
Driver: Improve section about Java #402
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
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3c37176
Connect/Java: Add information about jOOQ and Hibernate (JPA/Panache)
amotl e44ccaf
Connect/Java: Reorganize section
amotl 3dc4006
Connect/Java: Provide executable examples for JDBC
amotl 1469f4a
Connect/Java: Refurbish landing page
amotl 184d205
Connect/Java: Concise driver recommendations as suggested by CodeRabbit
amotl ff18c5b
Connect/Java: Absorb content about software testing
amotl 59b8ea3
Connect/Java: Wording. Clean up.
amotl 0fff874
Connect/Java: Clarify JDBC examples need Java 21 (JEP 330 => JEP 445)
amotl dcce170
Connect/Java: Reorganize JDBC pages
amotl eeec86e
Connect/Java: Implement suggestions by CodeRabbit
amotl ba1ed79
Connect/Java: Clarify JDBC examples need Java 25 (JEP 445 => JEP 512)
amotl 5d5de24
Connect/Java: Reorganize "install" vs. "run" sections
amotl 21addb8
Connect/Java: CI status badges for JDBC items
amotl 0d903ee
Connect/Java: Relocate CI status badge on jOOQ page
amotl ee9cb45
Connect/Java: Show full package name, including version number
amotl 38207f2
Connect/Java: Add references to Apache Flink and Apache Spark
amotl 0721159
Connect/Java: Add CI status badges instead of logos
amotl 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
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| <!-- markdownlint-disable MD034 --> | ||
| <!-- markdownlint-disable MD053 --> | ||
|
|
||
| [CrateDB home]: https://cratedb.com/ | ||
| [CrateDB logo]: https://avatars.githubusercontent.com/u/4048232?s=200&v=4 | ||
| [Hibernate logo]: https://logo.svgcdn.com/devicon/hibernate-original.svg | ||
| [jOOQ logo]: https://www.jooq.org/img/jooq-logo-black.png | ||
| [JUnit home]: https://junit.org/ | ||
| [JUnit logo]: https://avatars.githubusercontent.com/u/874086?s=200&v=4 | ||
| [PostgreSQL home]: https://www.postgresql.org/ | ||
| [PostgreSQL logo]: https://jdbc.postgresql.org/icons/postgreslogo.svg | ||
| [Testcontainers for Java]: https://testcontainers.com/guides/getting-started-with-testcontainers-for-java/ | ||
| [Testcontainers logo]: https://avatars.githubusercontent.com/u/13393021?s=200&v=4 |
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 |
|---|---|---|
|
|
@@ -176,7 +176,7 @@ application | |
| :maxdepth: 1 | ||
| :hidden: | ||
|
|
||
| java | ||
| java/index | ||
| javascript | ||
| php | ||
| python | ||
|
|
||
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| orphan: true | ||
| --- | ||
| :::{card} | ||
| :link: https://github.com/crate/cratedb-examples/tree/main/by-language/java-jdbc | ||
| :link-type: url | ||
| :width: 50% | ||
| {material-regular}`play_arrow;2em` | ||
| Connect to CrateDB using JDBC. | ||
| +++ | ||
| Demonstrates a basic example using both the vanilla PostgreSQL JDBC Driver | ||
| and the CrateDB JDBC Driver. | ||
| ::: |
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 |
|---|---|---|
| @@ -0,0 +1,152 @@ | ||
| :::{include} /_include/logos.md | ||
| ::: | ||
|
|
||
| (crate-jdbc)= | ||
| (cratedb-jdbc)= | ||
|
|
||
| # CrateDB JDBC | ||
|
|
||
| ```{div} .float-right | ||
| [![CrateDB logo][CrateDB logo]{height=40px loading=lazy}][CrateDB home] | ||
| ``` | ||
| ```{div} .clearfix | ||
| ``` | ||
|
|
||
| :::{include} /_include/links.md | ||
| ::: | ||
|
|
||
| :::{div} sd-text-muted | ||
| Connect to CrateDB using CrateDB JDBC. | ||
| ::: | ||
|
|
||
| :::{rubric} About | ||
| ::: | ||
|
|
||
| :::{div} | ||
| The [CrateDB JDBC Driver] is an open-source JDBC driver written in | ||
| Pure Java (Type 4), which communicates using the PostgreSQL native | ||
| network protocol. CrateDB JDBC needs Java >= 11. | ||
| ::: | ||
|
|
||
| :::{rubric} Synopsis | ||
| ::: | ||
|
|
||
| `example.java` | ||
| ```java | ||
| import java.sql.*; | ||
|
|
||
| void main() throws SQLException { | ||
|
|
||
| // Connect to database. | ||
| Properties properties = new Properties(); | ||
| properties.put("user", "crate"); | ||
| properties.put("password", "crate"); | ||
| Connection conn = DriverManager.getConnection( | ||
| "jdbc:crate://localhost:5432/doc?sslmode=disable", | ||
| properties | ||
| ); | ||
| conn.setAutoCommit(true); | ||
|
|
||
| // Invoke query. | ||
| Statement st = conn.createStatement(); | ||
| st.execute("SELECT mountain, height FROM sys.summits ORDER BY height DESC LIMIT 5;"); | ||
|
|
||
| // Display results. | ||
| ResultSet rs = st.getResultSet(); | ||
| while (rs.next()) { | ||
| System.out.printf(Locale.ENGLISH, "%s: %d\n", rs.getString(1), rs.getInt(2)); | ||
| } | ||
| conn.close(); | ||
|
|
||
| } | ||
| ``` | ||
|
|
||
| :::{rubric} CrateDB Cloud | ||
| ::: | ||
|
|
||
| For connecting to CrateDB Cloud, use the `sslmode=require` parameter, | ||
| and replace username, password, and hostname with values matching | ||
| your environment. | ||
| ```java | ||
| properties.put("user", "admin"); | ||
| properties.put("password", "password"); | ||
| Connection conn = DriverManager.getConnection( | ||
| "jdbc:crate://testcluster.cratedb.net:5432/doc?sslmode=require", | ||
| properties | ||
| ); | ||
| ``` | ||
|
|
||
| ## Install | ||
|
|
||
| :::{rubric} Download | ||
| ::: | ||
|
|
||
| :::{card} | ||
| :link: https://cratedb.com/docs/jdbc/en/latest/getting-started.html#installation | ||
| :link-type: url | ||
| {material-regular}`download;2em` | ||
| Navigate to the CrateDB JDBC Driver installation page. | ||
| ::: | ||
|
|
||
| :::{card} | ||
| :link: https://repo1.maven.org/maven2/io/crate/crate-jdbc-standalone/2.7.0/crate-jdbc-standalone-2.7.0.jar | ||
| :link-type: url | ||
| {material-regular}`download;2em` | ||
| Directly download the recommended `crate-jdbc-standalone-2.7.0.jar`. | ||
| ::: | ||
|
|
||
| :::{rubric} Maven `pom.xml` | ||
| ::: | ||
| ```xml | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>io.crate</groupId> | ||
| <artifactId>crate-jdbc</artifactId> | ||
| <version>2.7.0</version> | ||
| </dependency> | ||
| </dependencies> | ||
| ``` | ||
|
|
||
| :::{rubric} Gradle `build.gradle` | ||
| ::: | ||
| ```groovy | ||
| repositories { | ||
| mavenCentral() | ||
| } | ||
| dependencies { | ||
| implementation 'io.crate:crate-jdbc:2.7.0' | ||
| } | ||
| ``` | ||
|
|
||
| ## Quickstart example | ||
|
|
||
| Create a file `example.java` including the synopsis code shared above. | ||
|
|
||
| :::{include} ../_cratedb.md | ||
| ::: | ||
| Download JAR file. | ||
| ```shell | ||
| wget https://repo1.maven.org/maven2/io/crate/crate-jdbc-standalone/2.7.0/crate-jdbc-standalone-2.7.0.jar | ||
| ``` | ||
| :::{dropdown} Instructions for Windows users | ||
| If you don't have the `wget` program installed, for example on Windows, just | ||
| download the JAR file using your web browser of choice. | ||
| If you want to use PowerShell, invoke the `Invoke-WebRequest` command instead | ||
| of `wget`. | ||
| ```powershell | ||
| Invoke-WebRequest https://repo1.maven.org/maven2/io/crate/crate-jdbc-standalone/2.7.0/crate-jdbc-standalone-2.7.0.jar -OutFile crate-jdbc-standalone-2.7.0.jar | ||
| ``` | ||
| ::: | ||
| Invoke program. Needs Java >= 21 ([JEP 445]), alternatively see [](#full-example). | ||
| ```shell | ||
| java -cp crate-jdbc-standalone-2.7.0.jar example.java | ||
| ``` | ||
|
|
||
|
|
||
| ## Full example | ||
|
|
||
| :::{include} _jdbc_example.md | ||
| ::: | ||
|
|
||
|
|
||
| [JEP 445]: https://openjdk.org/jeps/445 | ||
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.
Uh oh!
There was an error while loading. Please reload this page.