TDengine/docs/examples/JDBC/SpringJdbcTemplate
She Yanjie 6f88b2c30a
docs: jdbc release 3.6.1, and update some comments (#30809)
* taoskeeper support new adapter metrics: connection pool and status

* jdbc 3.6.1 released, and update some comments
2025-04-17 10:01:44 +08:00
..
src move sample code to docs/example 2024-08-22 18:15:02 +08:00
.gitignore move sample code to docs/example 2024-08-22 18:15:02 +08:00
pom.xml docs: jdbc release 3.6.1, and update some comments (#30809) 2025-04-17 10:01:44 +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