TDengine/docs/examples/JDBC/SpringJdbcTemplate
She Yanjie 05ba8289a5
docs: jdbc release 3.7.6 (#33293)
* chore(jdbc): update jdbc version

* docs: jdbc release 3.7.6

* Update docs/en/14-reference/05-connector/14-java.md

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-10-17 16:24:15 +08:00
..
src docs(jdbc): jdbc release 3.7.2 (#32565) 2025-08-13 12:02:46 +08:00
.gitignore move sample code to docs/example 2024-08-22 18:15:02 +08:00
pom.xml docs: jdbc release 3.7.6 (#33293) 2025-10-17 16:24:15 +08:00
readme.md mod java code comments 2024-10-01 10:44:37 +08:00

TDengine Spring JDBC Template Demo

Spring JDBC Template simplifies the operations of acquiring and releasing native JDBC Connections, making database operations more convenient.

Configuration

Modify the TDengine configuration in the src/main/resources/applicationContext.xml file:

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.taosdata.jdbc.TSDBDriver"></property>
    <property name="url" value="jdbc:TAOS://127.0.0.1:6030/test"></property>
    <property name="username" value="root"></property>
    <property name="password" value="taosdata"></property>
</bean>

<bean id = "jdbcTemplate"  class="org.springframework.jdbc.core.JdbcTemplate" >
    <property name="dataSource" ref = "dataSource" ></property>
</bean>

Package and run

Navigate to the TDengine/tests/examples/JDBC/SpringJdbcTemplate directory and execute the following commands to generate an executable jar file.

mvn clean package

After successfully packaging, navigate to the target/ directory and execute the following commands to run the tests:

java -jar target/SpringJdbcTemplate-1.0-SNAPSHOT-jar-with-dependencies.jar