| // Do not edit directly! |
| // This file was generated by camel-quarkus-maven-plugin:update-extension-doc-page |
| [id="extensions-sql"] |
| = SQL |
| :page-aliases: extensions/sql.adoc |
| :linkattrs: |
| :cq-artifact-id: camel-quarkus-sql |
| :cq-native-supported: true |
| :cq-status: Stable |
| :cq-status-deprecation: Stable |
| :cq-description: Perform SQL queries. |
| :cq-deprecated: false |
| :cq-jvm-since: 1.0.0 |
| :cq-native-since: 1.0.0 |
| |
| ifeval::[{doc-show-badges} == true] |
| [.badges] |
| [.badge-key]##JVM since##[.badge-supported]##1.0.0## [.badge-key]##Native since##[.badge-supported]##1.0.0## |
| endif::[] |
| |
| Perform SQL queries. |
| |
| [id="extensions-sql-whats-inside"] |
| == What's inside |
| |
| * xref:{cq-camel-components}::sql-component.adoc[SQL component], URI syntax: `sql:query` |
| * xref:{cq-camel-components}::sql-stored-component.adoc[SQL Stored Procedure component], URI syntax: `sql-stored:template` |
| |
| Please refer to the above links for usage and configuration details. |
| |
| [id="extensions-sql-maven-coordinates"] |
| == Maven coordinates |
| |
| https://{link-quarkus-code-generator}/?extension-search=camel-quarkus-sql[Create a new project with this extension on {link-quarkus-code-generator}, window="_blank"] |
| |
| Or add the coordinates to your existing project: |
| |
| [source,xml] |
| ---- |
| <dependency> |
| <groupId>org.apache.camel.quarkus</groupId> |
| <artifactId>camel-quarkus-sql</artifactId> |
| </dependency> |
| ---- |
| ifeval::[{doc-show-user-guide-link} == true] |
| Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications. |
| endif::[] |
| |
| [id="extensions-sql-additional-camel-quarkus-configuration"] |
| == Additional Camel Quarkus configuration |
| |
| [id="extensions-sql-configuration-configuring-a-datasource"] |
| === Configuring a DataSource |
| |
| This extension leverages https://quarkus.io/guides/datasource[Quarkus Agroal] for `DataSource` support. Setting up a `DataSource` can be achieved via configuration properties. |
| |
| [source,properties] |
| ---- |
| quarkus.datasource.db-kind=postgresql |
| quarkus.datasource.username=your-username |
| quarkus.datasource.password=your-password |
| quarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/your-database |
| quarkus.datasource.jdbc.max-size=16 |
| ---- |
| |
| The Camel SQL component will automatically resolve the `DataSource` bean from the registry. When configuring multiple datasources, you can specify which one is to be used on an SQL endpoint via |
| the URI options `datasource` or `dataSourceRef`. Refer to the SQL component documentation for more details. |
| |
| [id="extensions-sql-configuration-zero-configuration-with-quarkus-dev-services"] |
| ==== Zero configuration with Quarkus Dev Services |
| |
| In dev and test mode you can take advantage of https://quarkus.io/guides/datasource#dev-services-configuration-free-databases[Configuration Free Databases]. The Camel SQL component will be automatically configured to use a `DataSource` that points to a local containerized instance of the database matching the JDBC driver type that you have selected. |
| |
| [id="extensions-sql-configuration-sql-scripts"] |
| === SQL scripts |
| |
| When configuring `sql` or `sql-stored` endpoints to reference script files from the classpath, set the following configuration property to ensure that they are available in native mode. |
| |
| [source,properties] |
| ---- |
| quarkus.native.resources.includes = queries.sql, sql/*.sql |
| ---- |
| |
| [id="extensions-sql-configuration-sql-aggregation-repository-in-native-mode"] |
| === SQL aggregation repository in native mode |
| |
| In order to use SQL aggregation repositories like `JdbcAggregationRepository` in native mode, you must xref:extensions/core.adoc#quarkus.camel.native.reflection.serialization-enabled[enable native serialization support]. |
| |
| In addition, if your exchange bodies are custom types, they must be registered for serialization by annotating their class declaration with `@RegisterForReflection(serialization = true)`. |
| |