commit
e46de616a6
|
@ -47,7 +47,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.taosdata.jdbc</groupId>
|
<groupId>com.taosdata.jdbc</groupId>
|
||||||
<artifactId>taos-jdbcdriver</artifactId>
|
<artifactId>taos-jdbcdriver</artifactId>
|
||||||
<version>2.0.4</version>
|
<version>2.0.18</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
<mainClass>com.taosdata.jdbc.example.jdbcTemplate.App</mainClass>
|
<mainClass>com.taosdata.example.jdbcTemplate.App</mainClass>
|
||||||
</manifest>
|
</manifest>
|
||||||
</archive>
|
</archive>
|
||||||
<descriptorRefs>
|
<descriptorRefs>
|
||||||
|
|
|
@ -8,18 +8,16 @@
|
||||||
修改 `src/main/resources/applicationContext.xml` 文件中 TDengine 的配置信息:
|
修改 `src/main/resources/applicationContext.xml` 文件中 TDengine 的配置信息:
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
|
<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/log"></property>
|
||||||
|
<property name="username" value="root"></property>
|
||||||
|
<property name="password" value="taosdata"></property>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
<bean id = "jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate" >
|
||||||
<property name="driverClassName" value="com.taosdata.jdbc.TSDBDriver"></property>
|
<property name="dataSource" ref = "dataSource" ></property>
|
||||||
<property name="url" value="jdbc:TAOS://127.0.0.1:6030/log"></property>
|
</bean>
|
||||||
<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>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 打包运行
|
### 打包运行
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.taosdata.jdbc.example.jdbcTemplate;
|
package com.taosdata.example.jdbcTemplate;
|
||||||
|
|
||||||
|
|
||||||
import com.taosdata.jdbc.example.jdbcTemplate.dao.ExecuteAsStatement;
|
import com.taosdata.example.jdbcTemplate.dao.ExecuteAsStatement;
|
||||||
import com.taosdata.jdbc.example.jdbcTemplate.dao.WeatherDao;
|
import com.taosdata.example.jdbcTemplate.dao.WeatherDao;
|
||||||
import com.taosdata.jdbc.example.jdbcTemplate.domain.Weather;
|
import com.taosdata.example.jdbcTemplate.domain.Weather;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package com.taosdata.jdbc.example.jdbcTemplate.dao;
|
package com.taosdata.example.jdbcTemplate.dao;
|
||||||
|
|
||||||
public interface ExecuteAsStatement{
|
public interface ExecuteAsStatement{
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package com.taosdata.jdbc.example.jdbcTemplate.dao.impl;
|
package com.taosdata.example.jdbcTemplate.dao;
|
||||||
|
|
||||||
import com.taosdata.jdbc.example.jdbcTemplate.dao.ExecuteAsStatement;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
|
@ -1,6 +1,6 @@
|
||||||
package com.taosdata.jdbc.example.jdbcTemplate.dao;
|
package com.taosdata.example.jdbcTemplate.dao;
|
||||||
|
|
||||||
import com.taosdata.jdbc.example.jdbcTemplate.domain.Weather;
|
import com.taosdata.example.jdbcTemplate.domain.Weather;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -1,20 +1,16 @@
|
||||||
package com.taosdata.jdbc.example.jdbcTemplate.dao.impl;
|
package com.taosdata.example.jdbcTemplate.dao;
|
||||||
|
|
||||||
import com.taosdata.jdbc.example.jdbcTemplate.dao.WeatherDao;
|
import com.taosdata.example.jdbcTemplate.domain.Weather;
|
||||||
import com.taosdata.jdbc.example.jdbcTemplate.domain.Weather;
|
import com.taosdata.example.jdbcTemplate.dao.WeatherDao;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
||||||
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
||||||
import org.springframework.jdbc.core.namedparam.SqlParameterSourceUtils;
|
|
||||||
import org.springframework.jdbc.core.simple.SimpleJdbcInsert;
|
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public class WeatherDaoImpl implements WeatherDao {
|
public class WeatherDaoImpl implements WeatherDao {
|
|
@ -1,4 +1,4 @@
|
||||||
package com.taosdata.jdbc.example.jdbcTemplate.domain;
|
package com.taosdata.example.jdbcTemplate.domain;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
|
||||||
<property name="driverClassName" value="com.taosdata.jdbc.TSDBDriver"></property>
|
<property name="driverClassName" value="com.taosdata.jdbc.TSDBDriver"></property>
|
||||||
<property name="url" value="jdbc:TAOS://192.168.236.137:6030/"></property>
|
<property name="url" value="jdbc:TAOS://127.0.0.1:6030/"></property>
|
||||||
<property name="username" value="root"></property>
|
<property name="username" value="root"></property>
|
||||||
<property name="password" value="taosdata"></property>
|
<property name="password" value="taosdata"></property>
|
||||||
</bean>
|
</bean>
|
||||||
|
@ -20,6 +20,6 @@
|
||||||
<property name="dataSource" ref="dataSource"></property>
|
<property name="dataSource" ref="dataSource"></property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<context:component-scan base-package="com.taosdata.jdbc.example.jdbcTemplate"/>
|
<context:component-scan base-package="com.taosdata.example.jdbcTemplate"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
package com.taosdata.jdbc.example.jdbcTemplate;
|
package com.taosdata.example.jdbcTemplate;
|
||||||
|
|
||||||
|
|
||||||
import com.taosdata.jdbc.example.jdbcTemplate.dao.ExecuteAsStatement;
|
import com.taosdata.example.jdbcTemplate.dao.ExecuteAsStatement;
|
||||||
import com.taosdata.jdbc.example.jdbcTemplate.dao.WeatherDao;
|
import com.taosdata.example.jdbcTemplate.dao.WeatherDao;
|
||||||
import com.taosdata.jdbc.example.jdbcTemplate.domain.Weather;
|
import com.taosdata.example.jdbcTemplate.domain.Weather;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
|
@ -1,18 +0,0 @@
|
||||||
package com.taosdata.jdbc;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unit test for simple App.
|
|
||||||
*/
|
|
||||||
public class AppTest {
|
|
||||||
/**
|
|
||||||
* Rigorous Test :-)
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void shouldAnswerWithTrue() {
|
|
||||||
assertTrue(true);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
# TDengine examples
|
||||||
|
|
||||||
|
| No. | Name | Describe |
|
||||||
|
| :--: | :----------------: | ------------------------------------------------------------ |
|
||||||
|
| 1 | JDBCDemo | Example codes for JDBC-JNI, JDBC-RESTful, Subscribe |
|
||||||
|
| 2 | connectionPools | Example codes for HikariCP, Druid, dbcp, c3p0 connection pools |
|
||||||
|
| 3 | SpringJdbcTemplate | Example codes for spring jdbcTemplate |
|
||||||
|
| 4 | mybatisplus-demo | Example codes for mybatis |
|
||||||
|
| 5 | springbootdemo | Example codes for springboot |
|
||||||
|
| 6 | taosdemo | This is an internal tool for testing Our JDBC-JNI, JDBC-RESTful, RESTful interfaces |
|
||||||
|
|
||||||
|
|
||||||
|
more detail: https://www.taosdata.com/cn//documentation20/connector-java/
|
Loading…
Reference in New Issue