Package org.apache.calcite.avatica
Class ConnectStringParser
java.lang.Object
org.apache.calcite.avatica.ConnectStringParser
ConnectStringParser is a utility class that parses or creates a JDBC connect
string according to the
OLE DB Connection String Syntax.
This code was adapted from Mondrian's mondrian.olap.Util class. The primary differences between this and its Mondrian progenitor are:
- use of regular
Propertiesfor compatibility with the JDBC API (replaces Mondrian's use of its own order-preserving and case-insensitive PropertyList) - ability to pass to
parse(java.lang.String)a pre-existing Properties object into which properties are to be parsed, possibly overriding prior values - use of
SQLExceptions rather than uncheckedRuntimeExceptions - static members for parsing and creating connect strings
ConnectStringParser has a private constructor. Callers use the static members:
parse(String)- Parses the connect string into a new Properties object.
parse(String, Properties)- Parses the connect string into an existing Properties object.
getParamString(Properties)- Returns a param string, quoted and escaped as needed, to represent the supplied name-value pairs.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetParamString(Properties props) Returns a param string, quoted and escaped as needed, to represent the supplied name-value pairs.static PropertiesParses the connect string into a new Properties object.static Propertiesparse(String s, Properties props) Parses the connect string into an existing Properties object.toMap(Properties properties) Converts aPropertiesobject to a.Map<String, String>
-
Method Details
-
parse
Parses the connect string into a new Properties object.- Parameters:
s- connect string to parse- Returns:
- properties object with parsed params
- Throws:
SQLException- error parsing name-value pairs
-
parse
Parses the connect string into an existing Properties object.- Parameters:
s- connect string to parseprops- optional properties object, may benull- Returns:
- properties object with parsed params; if an input
propswas supplied, any duplicate properties will have been replaced by those from the connect string. - Throws:
SQLException- error parsing name-value pairs
-
getParamString
Returns a param string, quoted and escaped as needed, to represent the supplied name-value pairs.- Parameters:
props- name-value pairs- Returns:
- param string, never
null
-
toMap
Converts aPropertiesobject to a.Map<String, String>This is necessary because
Propertiesis a dinosaur class. It ought to extendMap<String,String>, but instead extends.Hashtable<Object,Object>Typical usage, to iterate over a
Properties:Properties properties;
for (Map.Entry<String, String> entry = Util.toMap(properties).entrySet()) {
println("key=" + entry.getKey() + ", value=" + entry.getValue());
}
-