Class UrlParser
- All Implemented Interfaces:
Cloneable
parse and verification of URL.
basic syntax :
jdbc:(mysql|mariadb):[replication:|failover|loadbalance:|aurora:]//<hostDescription>[,<hostDescription>]/[database>]
[?<key1>=<value1>[&<key2>=<value2>]]
hostDescription:
- simple :
<host>:<portnumber>
(for example
localhost:3306)
- complex :
address=[(type=(master|slave))][(port=<portnumber>)](host=<host>)
type is by default master
port is by default 3306
host can be dns name, ipv4 or ipv6.
in case of ipv6 and simple host description, the ip must
be written inside bracket.
exemple : jdbc:mariadb://[2001:0660:7401:0200:0000:0000:0edf:bdd7]:3306
Some examples :
jdbc:mariadb://localhost:3306/database?user=greg&password=pass
jdbc:mariadb://address=(type=master)(host=master1),address=(port=3307)(type=slave)(host=slave1)/database?user=greg&password=pass
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
acceptsUrl
(String url) Tell if mariadb driver accept url string.Permit to set parameters not forced.clone()
private static void
defineUrlParserParameters
(UrlParser urlParser, Properties properties, String hostAddressesString, String additionalParameters) Sets the parameters of the UrlParser instance: addresses, database and options.boolean
int
hashCode()
boolean
isAurora()
Detection of Aurora.boolean
private void
static UrlParser
static UrlParser
parse
(String url, Properties prop) Parse url connection string with additional properties.private static HaMode
parseHaMode
(String url, int separator) private static void
parseInternal
(UrlParser urlParser, String url, Properties properties) Parses the connection URL in order to set the UrlParser instance with all the information provided through the URL.void
Parse url connection string.void
setDatabase
(String database) private static void
setDefaultHostAddressType
(UrlParser urlParser) void
setHostAddresses
(List<HostAddress> addresses) private void
void
setPassword
(String password) protected void
setProperties
(String urlParameters) void
setUsername
(String username) toString()
ToString implementation.
-
Field Details
-
DISABLE_MYSQL_URL
- See Also:
-
URL_PARAMETER
-
AWS_PATTERN
-
database
-
options
-
addresses
-
haMode
-
initialUrl
-
multiMaster
private boolean multiMaster
-
-
Constructor Details
-
UrlParser
private UrlParser() -
UrlParser
-
-
Method Details
-
acceptsUrl
Tell if mariadb driver accept url string. (Correspond to interface java.jdbc.Driver.acceptsURL() method)- Parameters:
url
- url String- Returns:
- true if url string correspond.
-
parse
- Throws:
SQLException
-
parse
Parse url connection string with additional properties.- Parameters:
url
- connection stringprop
- properties- Returns:
- UrlParser instance
- Throws:
SQLException
- if parsing exception occur
-
parseInternal
private static void parseInternal(UrlParser urlParser, String url, Properties properties) throws SQLException Parses the connection URL in order to set the UrlParser instance with all the information provided through the URL.- Parameters:
urlParser
- object instance in which all data from the connection url is storedurl
- connection URLproperties
- properties- Throws:
SQLException
- if format is incorrect
-
defineUrlParserParameters
private static void defineUrlParserParameters(UrlParser urlParser, Properties properties, String hostAddressesString, String additionalParameters) Sets the parameters of the UrlParser instance: addresses, database and options. It parses through the additional parameters given in order to extract the database and the options for the connection.- Parameters:
urlParser
- object instance in which all data from the connection URL is storedproperties
- propertieshostAddressesString
- string that holds all the host addressesadditionalParameters
- string that holds all parameters defined for the connection
-
parseHaMode
-
setDefaultHostAddressType
-
setInitialUrl
private void setInitialUrl() -
auroraPipelineQuirks
Permit to set parameters not forced. if options useBatchMultiSend and usePipelineAuth are not explicitly set in connection string, value will default to true or false according if aurora detection.- Returns:
- UrlParser for easy testing
-
isAurora
public boolean isAurora()Detection of Aurora.Aurora rely on MySQL, then cannot be identified by protocol. But Aurora doesn't permit some behaviour normally working with MySQL : pipelining. So Driver must identified if server is Aurora to disable pipeline options that are enable by default.
- Returns:
- true if aurora.
-
parseUrl
Parse url connection string.- Parameters:
url
- connection string- Throws:
SQLException
- if url format is incorrect
-
getUsername
-
setUsername
-
getPassword
-
setPassword
-
getDatabase
-
setDatabase
-
getHostAddresses
-
setHostAddresses
-
getOptions
-
setProperties
-
toString
ToString implementation. -
getInitialUrl
-
getHaMode
-
equals
-
hashCode
public int hashCode() -
loadMultiMasterValue
private void loadMultiMasterValue() -
isMultiMaster
public boolean isMultiMaster() -
clone
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-