This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 40adb82  fix a class name in jdbc module and reformat (#1817)
40adb82 is described below

commit 40adb8204ad1e0e35caa6fd1df398d1eaab54d9d
Author: Haonan <[email protected]>
AuthorDate: Tue Oct 13 08:51:09 2020 +0800

    fix a class name in jdbc module and reformat (#1817)
---
 .../main/java/org/apache/iotdb/jdbc/Activator.java |  21 +-
 .../org/apache/iotdb/jdbc/IoTDBDataSource.java     | 228 ++++++++++-----------
 .../apache/iotdb/jdbc/IoTDBDataSourceFactory.java  |  79 +++++++
 .../apache/iotdb/jdbc/IoTDbDataSourceFactory.java  |  79 -------
 4 files changed, 202 insertions(+), 205 deletions(-)

diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/Activator.java 
b/jdbc/src/main/java/org/apache/iotdb/jdbc/Activator.java
index 5c09771..ab72ee0 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/Activator.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/Activator.java
@@ -19,22 +19,21 @@ package org.apache.iotdb.jdbc;
 import org.osgi.framework.BundleActivator;
 import org.osgi.framework.BundleContext;
 import org.osgi.service.jdbc.DataSourceFactory;
-import org.apache.iotdb.jdbc.IoTDBDriver;
 import java.util.Dictionary;
 import java.util.Hashtable;
 
 public class Activator implements BundleActivator {
 
-    public void start(BundleContext context) {
-        IoTDbDataSourceFactory dsf = new IoTDbDataSourceFactory();
-        Dictionary<String, String> props = new Hashtable<String, String>();
-        props.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, 
IoTDBDriver.class.getName());
-        props.put(DataSourceFactory.OSGI_JDBC_DRIVER_NAME, "iotdb");
-        context.registerService(DataSourceFactory.class.getName(), dsf, props);
-    }
+  public void start(BundleContext context) {
+    IoTDBDataSourceFactory dsf = new IoTDBDataSourceFactory();
+    Dictionary<String, String> props = new Hashtable<String, String>();
+    props.put(DataSourceFactory.OSGI_JDBC_DRIVER_CLASS, 
IoTDBDriver.class.getName());
+    props.put(DataSourceFactory.OSGI_JDBC_DRIVER_NAME, "iotdb");
+    context.registerService(DataSourceFactory.class.getName(), dsf, props);
+  }
 
-    public void stop(BundleContext context) {
-        // EMPTY
-    }
+  public void stop(BundleContext context) {
+    // EMPTY
+  }
 
 }
\ No newline at end of file
diff --git a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSource.java 
b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSource.java
index 2d92a33..9630ae2 100644
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSource.java
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSource.java
@@ -28,119 +28,117 @@ import org.slf4j.LoggerFactory;
 
 public class IoTDBDataSource implements DataSource {
 
-    private final Logger logger = 
LoggerFactory.getLogger(IoTDBDataSource.class);
-
-    private String url;
-    private String user;
-    private String password;
-    private Properties properties;
-    private Integer port = 6667;
-
-    public IoTDBDataSource() {
-        properties = new Properties();
-    }
-
-    public IoTDBDataSource(String url, String user, String password, Integer 
port) {
-        this.url = url;
-        this.properties = new Properties();
-        properties.setProperty("user",user);
-        properties.setProperty("password",password);
-        if(port!=0) {
-            this.port = port;
-        }
-    }
-
-    public String getUser() {
-        return user;
-    }
-
-    public void setUser(String user) {
-        this.user = user;
-        properties.setProperty("user",user);
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setPassword(String password) {
-        this.password = password;
-        properties.setProperty("password",password);
-    }
-
-    public Integer getPort() {
-        return port;
-    }
-
-    public void setPort(Integer port) {
-        this.port = port;
-    }
-
-    public String getUrl() {
-        return url;
-    }
-
-    public void setUrl(String url) {
-        this.url = url;
-    }
-
-    @Override
-    public Connection getConnection() throws SQLException {
-        try {
-            return new IoTDBConnection(url, properties);
-        } catch (TTransportException e) {
-            e.printStackTrace();
-        }
-        return null;
-    }
-
-    @Override
-    public Connection getConnection(String username, String password) throws 
SQLException {
-       try {
-           Properties newProp = new Properties();
-           newProp.setProperty("user",username);
-           newProp.setProperty("password",password);
-           return new IoTDBConnection(url, newProp);
-       }
-       catch (Exception e){
-           e.printStackTrace();
-       }
-       return null;
-    }
-
-
-    @Override
-    public PrintWriter getLogWriter() throws SQLException {
-        return null;
-    }
-
-    @Override
-    public void setLogWriter(PrintWriter printWriter) throws SQLException {
-
-    }
-
-    @Override
-    public void setLoginTimeout(int i) throws SQLException {
-
-    }
-
-    @Override
-    public int getLoginTimeout() throws SQLException {
-        return 0;
-    }
-
-    @Override
-    public java.util.logging.Logger getParentLogger() throws 
SQLFeatureNotSupportedException {
-        return null;
-    }
-
-    @Override
-    public <T> T unwrap(Class<T> aClass) throws SQLException {
-        return null;
-    }
-
-    @Override
-    public boolean isWrapperFor(Class<?> aClass) throws SQLException {
-        return false;
-    }
+  private final Logger logger = LoggerFactory.getLogger(IoTDBDataSource.class);
+
+  private String url;
+  private String user;
+  private String password;
+  private Properties properties;
+  private Integer port = 6667;
+
+  public IoTDBDataSource() {
+    properties = new Properties();
+  }
+
+  public IoTDBDataSource(String url, String user, String password, Integer 
port) {
+    this.url = url;
+    this.properties = new Properties();
+    properties.setProperty("user", user);
+    properties.setProperty("password", password);
+    if (port != 0) {
+      this.port = port;
+    }
+  }
+
+  public String getUser() {
+    return user;
+  }
+
+  public void setUser(String user) {
+    this.user = user;
+    properties.setProperty("user", user);
+  }
+
+  public String getPassword() {
+    return password;
+  }
+
+  public void setPassword(String password) {
+    this.password = password;
+    properties.setProperty("password", password);
+  }
+
+  public Integer getPort() {
+    return port;
+  }
+
+  public void setPort(Integer port) {
+    this.port = port;
+  }
+
+  public String getUrl() {
+    return url;
+  }
+
+  public void setUrl(String url) {
+    this.url = url;
+  }
+
+  @Override
+  public Connection getConnection() throws SQLException {
+    try {
+      return new IoTDBConnection(url, properties);
+    } catch (TTransportException e) {
+      e.printStackTrace();
+    }
+    return null;
+  }
+
+  @Override
+  public Connection getConnection(String username, String password) throws 
SQLException {
+    try {
+      Properties newProp = new Properties();
+      newProp.setProperty("user", username);
+      newProp.setProperty("password", password);
+      return new IoTDBConnection(url, newProp);
+    } catch (Exception e) {
+      e.printStackTrace();
+    }
+    return null;
+  }
+
+  @Override
+  public PrintWriter getLogWriter() throws SQLException {
+    return null;
+  }
+
+  @Override
+  public void setLogWriter(PrintWriter printWriter) throws SQLException {
+
+  }
+
+  @Override
+  public void setLoginTimeout(int i) throws SQLException {
+
+  }
+
+  @Override
+  public int getLoginTimeout() throws SQLException {
+    return 0;
+  }
+
+  @Override
+  public java.util.logging.Logger getParentLogger() throws 
SQLFeatureNotSupportedException {
+    return null;
+  }
+
+  @Override
+  public <T> T unwrap(Class<T> aClass) throws SQLException {
+    return null;
+  }
+
+  @Override
+  public boolean isWrapperFor(Class<?> aClass) throws SQLException {
+    return false;
+  }
 }
diff --git 
a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSourceFactory.java 
b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSourceFactory.java
new file mode 100644
index 0000000..40088dd
--- /dev/null
+++ b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDBDataSourceFactory.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.iotdb.jdbc;
+
+import org.ops4j.pax.jdbc.common.BeanConfig;
+import org.osgi.service.jdbc.DataSourceFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.sql.ConnectionPoolDataSource;
+import javax.sql.DataSource;
+import javax.sql.XADataSource;
+import java.sql.Driver;
+import java.sql.SQLException;
+import java.util.Properties;
+
+public class IoTDBDataSourceFactory implements DataSourceFactory {
+
+  private final Logger logger = 
LoggerFactory.getLogger(IoTDBDataSourceFactory.class);
+
+  @Override
+  public DataSource createDataSource(Properties properties) throws 
SQLException {
+    IoTDBDataSource ds = new IoTDBDataSource();
+    setProperties(ds, properties);
+    return ds;
+  }
+
+  public void setProperties(IoTDBDataSource ds, Properties prop) {
+    Properties properties = (Properties) prop.clone();
+    String url = (String) properties.remove(DataSourceFactory.JDBC_URL);
+    if (url != null) {
+      ds.setUrl(url);
+      logger.info("URL set {}", url);
+    }
+
+    String user = (String) properties.remove(DataSourceFactory.JDBC_USER);
+    ds.setUser(user);
+    logger.info("User set {}", user);
+
+    String password = (String) 
properties.remove(DataSourceFactory.JDBC_PASSWORD);
+    ds.setPassword(password);
+    logger.info("Password set {}", password);
+
+    logger.info("Remaining properties {}", properties.size());
+
+    if (!properties.isEmpty()) {
+      BeanConfig.configure(ds, properties);
+    }
+  }
+
+  @Override
+  public ConnectionPoolDataSource createConnectionPoolDataSource(Properties 
properties) throws SQLException {
+    return null;
+  }
+
+  @Override
+  public XADataSource createXADataSource(Properties properties) throws 
SQLException {
+    return null;
+  }
+
+  @Override
+  public Driver createDriver(Properties properties) throws SQLException {
+    return new IoTDBDriver();
+  }
+}
diff --git 
a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDbDataSourceFactory.java 
b/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDbDataSourceFactory.java
deleted file mode 100644
index f03c309..0000000
--- a/jdbc/src/main/java/org/apache/iotdb/jdbc/IoTDbDataSourceFactory.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.iotdb.jdbc;
-
-import org.ops4j.pax.jdbc.common.BeanConfig;
-import org.osgi.service.jdbc.DataSourceFactory;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.sql.ConnectionPoolDataSource;
-import javax.sql.DataSource;
-import javax.sql.XADataSource;
-import java.sql.Driver;
-import java.sql.SQLException;
-import java.util.Properties;
-
-public class IoTDbDataSourceFactory implements DataSourceFactory {
-    private final Logger logger = 
LoggerFactory.getLogger(IoTDbDataSourceFactory.class);
-    @Override
-    public DataSource createDataSource(Properties properties) throws 
SQLException {
-       IoTDBDataSource ds = new IoTDBDataSource();
-       setProperties(ds, properties);
-       return  ds;
-    }
-    public void setProperties(IoTDBDataSource ds, Properties prop){
-        Properties properties = (Properties)prop.clone();
-        String url = (String)properties.remove(DataSourceFactory.JDBC_URL);
-        if(url!=null){
-            ds.setUrl(url);
-            logger.info("URL set {}",url);
-        }
-
-        String user = (String) properties.remove(DataSourceFactory.JDBC_USER);
-        ds.setUser(user);
-        logger.info("User set {}",user);
-
-
-        String password = (String) 
properties.remove(DataSourceFactory.JDBC_PASSWORD);
-        ds.setPassword(password);
-        logger.info("Password set {}",password);
-
-
-        logger.info("Remaining properties {}", properties.size());
-
-        if (!properties.isEmpty()) {
-            BeanConfig.configure(ds, properties);
-        }
-    }
-
-    @Override
-    public ConnectionPoolDataSource createConnectionPoolDataSource(Properties 
properties) throws SQLException {
-        return null;
-    }
-
-    @Override
-    public XADataSource createXADataSource(Properties properties) throws 
SQLException {
-        return null;
-    }
-
-    @Override
-    public Driver createDriver(Properties properties) throws SQLException {
-        IoTDBDriver driver = new IoTDBDriver();
-        return driver;
-    }
-}

Reply via email to