Package com.taosdata.jdbc
Class TSDBDriver
- java.lang.Object
-
- com.taosdata.jdbc.TSDBDriver
-
- All Implemented Interfaces:
Driver
public class TSDBDriver extends Object implements Driver
The Java SQL framework allows for multiple database drivers. Each driver should supply a class that implements the Driver interfaceThe DriverManager will try to load as many drivers as it can find and then for any given connection request, it will ask each driver in turn to try to connect to the target URL.
It is strongly recommended that each Driver class should be small and stand alone so that the Driver class can be loaded and queried without bringing in vast quantities of supporting code.
When a Driver class is loaded, it should create an instance of itself and register it with the DriverManager. This means that a user can load and register a driver by doing Class.forName("foo.bah.Driver")
-
-
Field Summary
Fields Modifier and Type Field Description static intHOST_NAME_INDEXIndex for host coming out of parseHostPortPair().static intPORT_NUMBER_INDEXIndex for port coming out of parseHostPortPair().static StringPROPERTY_KEY_CHARSETKey for the char encoding used by the TSDB client in properties instancestatic StringPROPERTY_KEY_CONFIG_DIRKey for the configuration file directory of TSDB client in properties instancestatic StringPROPERTY_KEY_DBNAMEKey used to retrieve the database value from the properties instance passed to the driver.static StringPROPERTY_KEY_HOSTKey used to retrieve the host value from the properties instance passed to the driver.static StringPROPERTY_KEY_LOCALEKey for the locale used by the TSDB client in properties instancestatic StringPROPERTY_KEY_PASSWORDKey used to retrieve the password value from the properties instance passed to the driver.static StringPROPERTY_KEY_PORTKey used to retrieve the port number value from the properties instance passed to the driver.static StringPROPERTY_KEY_PROTOCOLstatic StringPROPERTY_KEY_TIME_ZONEKey for the timezone used by the TSDB client in properties instancestatic StringPROPERTY_KEY_USERKey used to retrieve the user value from the properties instance passed to the driver.
-
Constructor Summary
Constructors Constructor Description TSDBDriver()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacceptsURL(String url)Connectionconnect(String url, Properties info)Stringdatabase(Properties props)Returns the database property frompropsintgetMajorVersion()intgetMinorVersion()LoggergetParentLogger()DriverPropertyInfo[]getPropertyInfo(String url, Properties info)Stringhost(Properties props)Returns the host propertybooleanjdbcCompliant()protected static String[]parseHostPortPair(String hostPortPair)Parses hostPortPair in the form of [host][:port] into an array, with the element of index HOST_NAME_INDEX being the host (or null if not specified), and the element of index PORT_NUMBER_INDEX being the port (or null if not specified).PropertiesparseURL(String url, Properties defaults)example: jdbc:TSDB://127.0.0.1:0/db?user=root&password=your_passwordintport(Properties props)Returns the port number propertyvoidsetPropertyValue(Properties property, String[] keyValuePair)
-
-
-
Field Detail
-
PROPERTY_KEY_DBNAME
public static final String PROPERTY_KEY_DBNAME
Key used to retrieve the database value from the properties instance passed to the driver.- See Also:
- Constant Field Values
-
PROPERTY_KEY_HOST
public static final String PROPERTY_KEY_HOST
Key used to retrieve the host value from the properties instance passed to the driver.- See Also:
- Constant Field Values
-
PROPERTY_KEY_PASSWORD
public static final String PROPERTY_KEY_PASSWORD
Key used to retrieve the password value from the properties instance passed to the driver.- See Also:
- Constant Field Values
-
PROPERTY_KEY_PORT
public static final String PROPERTY_KEY_PORT
Key used to retrieve the port number value from the properties instance passed to the driver.- See Also:
- Constant Field Values
-
PROPERTY_KEY_USER
public static final String PROPERTY_KEY_USER
Key used to retrieve the user value from the properties instance passed to the driver.- See Also:
- Constant Field Values
-
PROPERTY_KEY_CONFIG_DIR
public static final String PROPERTY_KEY_CONFIG_DIR
Key for the configuration file directory of TSDB client in properties instance- See Also:
- Constant Field Values
-
PROPERTY_KEY_TIME_ZONE
public static final String PROPERTY_KEY_TIME_ZONE
Key for the timezone used by the TSDB client in properties instance- See Also:
- Constant Field Values
-
PROPERTY_KEY_LOCALE
public static final String PROPERTY_KEY_LOCALE
Key for the locale used by the TSDB client in properties instance- See Also:
- Constant Field Values
-
PROPERTY_KEY_CHARSET
public static final String PROPERTY_KEY_CHARSET
Key for the char encoding used by the TSDB client in properties instance- See Also:
- Constant Field Values
-
PROPERTY_KEY_PROTOCOL
public static final String PROPERTY_KEY_PROTOCOL
- See Also:
- Constant Field Values
-
PORT_NUMBER_INDEX
public static final int PORT_NUMBER_INDEX
Index for port coming out of parseHostPortPair().- See Also:
- Constant Field Values
-
HOST_NAME_INDEX
public static final int HOST_NAME_INDEX
Index for host coming out of parseHostPortPair().- See Also:
- Constant Field Values
-
-
Method Detail
-
connect
public Connection connect(String url, Properties info) throws SQLException
- Specified by:
connectin interfaceDriver- Throws:
SQLException
-
parseHostPortPair
protected static String[] parseHostPortPair(String hostPortPair) throws SQLException
Parses hostPortPair in the form of [host][:port] into an array, with the element of index HOST_NAME_INDEX being the host (or null if not specified), and the element of index PORT_NUMBER_INDEX being the port (or null if not specified).- Parameters:
hostPortPair- host and port in form of of [host][:port]- Returns:
- array containing host and port as Strings
- Throws:
SQLException- if a parse error occurs
-
acceptsURL
public boolean acceptsURL(String url) throws SQLException
- Specified by:
acceptsURLin interfaceDriver- Throws:
SQLException
-
getPropertyInfo
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException
- Specified by:
getPropertyInfoin interfaceDriver- Throws:
SQLException
-
parseURL
public Properties parseURL(String url, Properties defaults) throws SQLException
example: jdbc:TSDB://127.0.0.1:0/db?user=root&password=your_password- Throws:
SQLException
-
setPropertyValue
public void setPropertyValue(Properties property, String[] keyValuePair)
-
getMajorVersion
public int getMajorVersion()
- Specified by:
getMajorVersionin interfaceDriver
-
getMinorVersion
public int getMinorVersion()
- Specified by:
getMinorVersionin interfaceDriver
-
jdbcCompliant
public boolean jdbcCompliant()
- Specified by:
jdbcCompliantin interfaceDriver
-
getParentLogger
public Logger getParentLogger() throws SQLFeatureNotSupportedException
- Specified by:
getParentLoggerin interfaceDriver- Throws:
SQLFeatureNotSupportedException
-
host
public String host(Properties props)
Returns the host property- Parameters:
props- the java.util.Properties instance to retrieve the hostname from.- Returns:
- the host
-
port
public int port(Properties props)
Returns the port number property- Parameters:
props- the properties to get the port number from- Returns:
- the port number
-
database
public String database(Properties props)
Returns the database property fromprops- Parameters:
props- the Properties to look for the database property.- Returns:
- the database name.
-
-