提交 5f3af852 编写于 作者: S Shengliang Guan

Merge remote-tracking branch 'origin/develop' into feature/query

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.taosdata.jdbc</groupId> <groupId>com.taosdata.jdbc</groupId>
<artifactId>taos-jdbcdriver</artifactId> <artifactId>taos-jdbcdriver</artifactId>
<version>2.0.0</version> <version>2.0.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>JDBCDriver</name> <name>JDBCDriver</name>
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
<description>TDengine JDBC Driver</description>
<licenses>
<license>
<name>GNU AFFERO GENERAL PUBLIC LICENSE Version 3</name>
<url>https://github.com/taosdata/TDengine/blob/master/LICENSE</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git://github.com/taosdata/TDengine.git</connection>
<developerConnection>scm:git:git@github.com:taosdata/TDengine.git</developerConnection>
<url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url> <url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
<tag>HEAD</tag>
</scm> <description>TDengine JDBC Driver</description>
<developers> <licenses>
<developer> <license>
<name>taosdata</name> <name>GNU AFFERO GENERAL PUBLIC LICENSE Version 3</name>
<email>support@taosdata.com</email> <url>https://github.com/taosdata/TDengine/blob/master/LICENSE</url>
<organization>https://www.taosdata.com/</organization> <distribution>repo</distribution>
<organizationUrl>https://www.taosdata.com/</organizationUrl> </license>
</developer> </licenses>
</developers> <scm>
<properties> <connection>scm:git:git://github.com/taosdata/TDengine.git</connection>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <developerConnection>scm:git:git@github.com:taosdata/TDengine.git</developerConnection>
<java.version>1.8</java.version> <url>https://github.com/taosdata/TDengine/tree/master/src/connector/jdbc</url>
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version> <tag>HEAD</tag>
<commons-logging.version>1.1.2</commons-logging.version> </scm>
<commons-lang3.version>3.5</commons-lang3.version> <developers>
</properties> <developer>
<dependencies> <name>taosdata</name>
<dependency> <email>support@taosdata.com</email>
<groupId>commons-logging</groupId> <organization>https://www.taosdata.com/</organization>
<artifactId>commons-logging</artifactId> <organizationUrl>https://www.taosdata.com/</organizationUrl>
<version>${commons-logging.version}</version> </developer>
<exclusions> </developers>
<exclusion> <properties>
<groupId>*</groupId> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<artifactId>*</artifactId> <java.version>1.8</java.version>
</exclusion> <maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
</exclusions> <commons-logging.version>1.1.2</commons-logging.version>
</dependency> <commons-lang3.version>3.5</commons-lang3.version>
<dependency> </properties>
<groupId>junit</groupId> <dependencies>
<artifactId>junit</artifactId> <dependency>
<version>4.13</version> <groupId>commons-logging</groupId>
<scope>test</scope> <artifactId>commons-logging</artifactId>
</dependency> <version>${commons-logging.version}</version>
</dependencies> <exclusions>
<build> <exclusion>
<plugins> <groupId>*</groupId>
<plugin> <artifactId>*</artifactId>
<groupId>org.apache.maven.plugins</groupId> </exclusion>
<artifactId>maven-assembly-plugin</artifactId> </exclusions>
<version>3.0.0</version> </dependency>
<configuration> <dependency>
<descriptors> <groupId>junit</groupId>
<descriptor>src/main/assembly/assembly-jar.xml</descriptor> <artifactId>junit</artifactId>
</descriptors> <version>4.13</version>
</configuration> <scope>test</scope>
<executions> </dependency>
<execution> </dependencies>
<id>make-assembly</id> <build>
<phase>package</phase> <plugins>
<goals> <plugin>
<goal>single</goal> <groupId>org.apache.maven.plugins</groupId>
</goals> <artifactId>maven-assembly-plugin</artifactId>
</execution> <version>3.0.0</version>
</executions> <configuration>
</plugin> <descriptors>
<plugin> <descriptor>src/main/assembly/assembly-jar.xml</descriptor>
<groupId>org.apache.maven.plugins</groupId> </descriptors>
<artifactId>maven-compiler-plugin</artifactId> </configuration>
<version>${maven-compiler-plugin.version}</version> <executions>
<configuration> <execution>
<encoding>UTF-8</encoding> <id>make-assembly</id>
<source>${java.version}</source> <phase>package</phase>
<target>${java.version}</target> <goals>
<debug>true</debug> <goal>single</goal>
<showDeprecation>true</showDeprecation> </goals>
</configuration> </execution>
</plugin> </executions>
<plugin> </plugin>
<groupId>org.apache.maven.plugins</groupId> <plugin>
<artifactId>maven-surefire-plugin</artifactId> <groupId>org.apache.maven.plugins</groupId>
<version>2.12.4</version> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <version>${maven-compiler-plugin.version}</version>
<testFailureIgnore>true</testFailureIgnore> <configuration>
</configuration> <encoding>UTF-8</encoding>
</plugin> <source>${java.version}</source>
</plugins> <target>${java.version}</target>
</build> <debug>true</debug>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
</plugins>
</build>
</project> </project>
...@@ -53,66 +53,12 @@ public class TSDBConnection implements Connection { ...@@ -53,66 +53,12 @@ public class TSDBConnection implements Connection {
public TSDBConnection(Properties info, TSDBDatabaseMetaData meta) throws SQLException { public TSDBConnection(Properties info, TSDBDatabaseMetaData meta) throws SQLException {
this.dbMetaData = meta; this.dbMetaData = meta;
//load taos.cfg start
File cfgDir = loadConfigDir(info.getProperty(TSDBDriver.PROPERTY_KEY_CONFIG_DIR));
File cfgFile = cfgDir.listFiles((dir, name) -> "taos.cfg".equalsIgnoreCase(name))[0];
List<String> endpoints = loadConfigEndpoints(cfgFile);
if (!endpoints.isEmpty()) {
info.setProperty(TSDBDriver.PROPERTY_KEY_HOST, endpoints.get(0).split(":")[0]);
info.setProperty(TSDBDriver.PROPERTY_KEY_PORT, endpoints.get(0).split(":")[1]);
}
//load taos.cfg end
connect(info.getProperty(TSDBDriver.PROPERTY_KEY_HOST), connect(info.getProperty(TSDBDriver.PROPERTY_KEY_HOST),
Integer.parseInt(info.getProperty(TSDBDriver.PROPERTY_KEY_PORT, "0")), Integer.parseInt(info.getProperty(TSDBDriver.PROPERTY_KEY_PORT, "0")),
info.getProperty(TSDBDriver.PROPERTY_KEY_DBNAME), info.getProperty(TSDBDriver.PROPERTY_KEY_USER), info.getProperty(TSDBDriver.PROPERTY_KEY_DBNAME), info.getProperty(TSDBDriver.PROPERTY_KEY_USER),
info.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD)); info.getProperty(TSDBDriver.PROPERTY_KEY_PASSWORD));
} }
private List<String> loadConfigEndpoints(File cfgFile) {
List<String> endpoints = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new FileReader(cfgFile))) {
String line = null;
while ((line = reader.readLine()) != null) {
if (line.trim().startsWith("firstEp") || line.trim().startsWith("secondEp")) {
endpoints.add(line.substring(line.indexOf('p') + 1).trim());
}
if (endpoints.size() > 1)
break;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return endpoints;
}
/**
* @param cfgDirPath
* @return return the config dir
**/
private File loadConfigDir(String cfgDirPath) {
if (cfgDirPath == null)
return loadDefaultConfigDir();
File cfgDir = new File(cfgDirPath);
if (!cfgDir.exists())
return loadDefaultConfigDir();
return cfgDir;
}
/**
* @return search the default config dir, if the config dir is not exist will return null
*/
private File loadDefaultConfigDir() {
File cfgDir;
File cfgDir_linux = new File("/etc/taos");
cfgDir = cfgDir_linux.exists() ? cfgDir_linux : null;
File cfgDir_windows = new File("C:\\TDengine\\cfg");
cfgDir = (cfgDir == null && cfgDir_windows.exists()) ? cfgDir_windows : cfgDir;
return cfgDir;
}
private void connect(String host, int port, String dbName, String user, String password) throws SQLException { private void connect(String host, int port, String dbName, String user, String password) throws SQLException {
this.connector = new TSDBJNIConnector(); this.connector = new TSDBJNIConnector();
this.connector.connect(host, port, dbName, user, password); this.connector.connect(host, port, dbName, user, password);
......
...@@ -68,15 +68,15 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData { ...@@ -68,15 +68,15 @@ public class TSDBDatabaseMetaData implements java.sql.DatabaseMetaData {
} }
public boolean nullsAreSortedLow() throws SQLException { public boolean nullsAreSortedLow() throws SQLException {
return false; return !nullsAreSortedHigh();
} }
public boolean nullsAreSortedAtStart() throws SQLException { public boolean nullsAreSortedAtStart() throws SQLException {
return false; return true;
} }
public boolean nullsAreSortedAtEnd() throws SQLException { public boolean nullsAreSortedAtEnd() throws SQLException {
return false; return !nullsAreSortedAtStart();
} }
public String getDatabaseProductName() throws SQLException { public String getDatabaseProductName() throws SQLException {
......
...@@ -242,7 +242,7 @@ public class TSDBStatement implements Statement { ...@@ -242,7 +242,7 @@ public class TSDBStatement implements Statement {
public void addBatch(String sql) throws SQLException { public void addBatch(String sql) throws SQLException {
if (batchedArgs == null) { if (batchedArgs == null) {
batchedArgs = new ArrayList<String>(); batchedArgs = new ArrayList<>();
} }
batchedArgs.add(sql); batchedArgs.add(sql);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册