提交 e56abac7 编写于 作者: Z zyyang

change

上级 0f9ad76f
...@@ -981,9 +981,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData, Wrap ...@@ -981,9 +981,7 @@ public abstract class AbstractDatabaseMetaData implements DatabaseMetaData, Wrap
return getEmptyResultSet(); return getEmptyResultSet();
} }
public Connection getConnection() throws SQLException { public abstract Connection getConnection() throws SQLException;
return null;
}
public boolean supportsSavepoints() throws SQLException { public boolean supportsSavepoints() throws SQLException {
return false; return false;
......
...@@ -90,7 +90,7 @@ public class TSDBDriver extends AbstractDriver { ...@@ -90,7 +90,7 @@ public class TSDBDriver extends AbstractDriver {
* fetch data from native function in a batch model * fetch data from native function in a batch model
*/ */
public static final String PROPERTY_KEY_BATCH_LOAD = "batchfetch"; public static final String PROPERTY_KEY_BATCH_LOAD = "batchfetch";
private TSDBDatabaseMetaData dbMetaData = null; private TSDBDatabaseMetaData dbMetaData = null;
static { static {
...@@ -179,18 +179,18 @@ public class TSDBDriver extends AbstractDriver { ...@@ -179,18 +179,18 @@ public class TSDBDriver extends AbstractDriver {
while (queryParams.hasMoreElements()) { while (queryParams.hasMoreElements()) {
String oneToken = queryParams.nextToken(); String oneToken = queryParams.nextToken();
String[] pair = oneToken.split("="); String[] pair = oneToken.split("=");
if ((pair[0] != null && pair[0].trim().length() > 0) && (pair[1] != null && pair[1].trim().length() > 0)) { if ((pair[0] != null && pair[0].trim().length() > 0) && (pair[1] != null && pair[1].trim().length() > 0)) {
urlProps.setProperty(pair[0].trim(), pair[1].trim()); urlProps.setProperty(pair[0].trim(), pair[1].trim());
} }
} }
} }
// parse Product Name // parse Product Name
String dbProductName = url.substring(0, beginningOfSlashes); String dbProductName = url.substring(0, beginningOfSlashes);
dbProductName = dbProductName.substring(dbProductName.indexOf(":") + 1); dbProductName = dbProductName.substring(dbProductName.indexOf(":") + 1);
dbProductName = dbProductName.substring(0, dbProductName.indexOf(":")); dbProductName = dbProductName.substring(0, dbProductName.indexOf(":"));
// parse database name // parse database name
url = url.substring(beginningOfSlashes + 2); url = url.substring(beginningOfSlashes + 2);
int indexOfSlash = url.indexOf("/"); int indexOfSlash = url.indexOf("/");
...@@ -200,7 +200,7 @@ public class TSDBDriver extends AbstractDriver { ...@@ -200,7 +200,7 @@ public class TSDBDriver extends AbstractDriver {
} }
url = url.substring(0, indexOfSlash); url = url.substring(0, indexOfSlash);
} }
// parse port // parse port
int indexOfColon = url.indexOf(":"); int indexOfColon = url.indexOf(":");
if (indexOfColon != -1) { if (indexOfColon != -1) {
...@@ -209,11 +209,11 @@ public class TSDBDriver extends AbstractDriver { ...@@ -209,11 +209,11 @@ public class TSDBDriver extends AbstractDriver {
} }
url = url.substring(0, indexOfColon); url = url.substring(0, indexOfColon);
} }
if (url != null && url.length() > 0 && url.trim().length() > 0) { if (url != null && url.length() > 0 && url.trim().length() > 0) {
urlProps.setProperty(TSDBDriver.PROPERTY_KEY_HOST, url); urlProps.setProperty(TSDBDriver.PROPERTY_KEY_HOST, url);
} }
this.dbMetaData = new TSDBDatabaseMetaData(urlForMeta, urlProps.getProperty(TSDBDriver.PROPERTY_KEY_USER)); this.dbMetaData = new TSDBDatabaseMetaData(urlForMeta, urlProps.getProperty(TSDBDriver.PROPERTY_KEY_USER));
return urlProps; return urlProps;
} }
......
package com.taosdata.jdbc.rs; package com.taosdata.jdbc.rs;
import com.taosdata.jdbc.AbstractDatabaseMetaData; import com.taosdata.jdbc.AbstractDatabaseMetaData;
import com.taosdata.jdbc.TSDBConstants; import com.taosdata.jdbc.TSDBError;
import com.taosdata.jdbc.TSDBErrorNumbers;
import java.sql.Connection; import java.sql.Connection;
import java.sql.ResultSet; import java.sql.ResultSet;
...@@ -34,11 +35,10 @@ public class RestfulDatabaseMetaData extends AbstractDatabaseMetaData { ...@@ -34,11 +35,10 @@ public class RestfulDatabaseMetaData extends AbstractDatabaseMetaData {
return RestfulDriver.class.getName(); return RestfulDriver.class.getName();
} }
@Override @Override
public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException { public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
if (connection == null || connection.isClosed()) { if (connection == null || connection.isClosed()) {
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
} }
return super.getTables(catalog, schemaPattern, tableNamePattern, types, connection); return super.getTables(catalog, schemaPattern, tableNamePattern, types, connection);
} }
...@@ -46,14 +46,14 @@ public class RestfulDatabaseMetaData extends AbstractDatabaseMetaData { ...@@ -46,14 +46,14 @@ public class RestfulDatabaseMetaData extends AbstractDatabaseMetaData {
@Override @Override
public ResultSet getCatalogs() throws SQLException { public ResultSet getCatalogs() throws SQLException {
if (connection == null || connection.isClosed()) if (connection == null || connection.isClosed())
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
return super.getCatalogs(connection); return super.getCatalogs(connection);
} }
@Override @Override
public ResultSet getTableTypes() throws SQLException { public ResultSet getTableTypes() throws SQLException {
if (connection == null || connection.isClosed()) { if (connection == null || connection.isClosed()) {
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
} }
return super.getTableTypes(); return super.getTableTypes();
} }
...@@ -61,21 +61,26 @@ public class RestfulDatabaseMetaData extends AbstractDatabaseMetaData { ...@@ -61,21 +61,26 @@ public class RestfulDatabaseMetaData extends AbstractDatabaseMetaData {
@Override @Override
public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException { public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
if (connection == null || connection.isClosed()) if (connection == null || connection.isClosed())
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
return super.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern, connection); return super.getColumns(catalog, schemaPattern, tableNamePattern, columnNamePattern, connection);
} }
@Override @Override
public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException { public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
if (connection == null || connection.isClosed()) if (connection == null || connection.isClosed())
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
return super.getPrimaryKeys(catalog, schema, table, connection); return super.getPrimaryKeys(catalog, schema, table, connection);
} }
@Override
public Connection getConnection() throws SQLException {
return this.connection;
}
@Override @Override
public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException { public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
if (connection == null || connection.isClosed()) if (connection == null || connection.isClosed())
throw new SQLException(TSDBConstants.FixErrMsg(TSDBConstants.JNI_CONNECTION_NULL)); throw TSDBError.createSQLException(TSDBErrorNumbers.ERROR_CONNECTION_CLOSED);
return super.getSuperTables(catalog, schemaPattern, tableNamePattern, connection); return super.getSuperTables(catalog, schemaPattern, tableNamePattern, connection);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册