public class UrlParser
extends java.lang.Object
implements java.lang.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
Modifier and Type | Field and Description |
---|---|
private java.util.List<HostAddress> |
addresses |
private static java.util.regex.Pattern |
AWS_PATTERN |
private java.lang.String |
database |
private static java.lang.String |
DISABLE_MYSQL_URL |
private HaMode |
haMode |
private java.lang.String |
initialUrl |
private boolean |
multiMaster |
private Options |
options |
private static java.util.regex.Pattern |
URL_PARAMETER |
Modifier | Constructor and Description |
---|---|
private |
UrlParser() |
protected |
UrlParser(java.lang.String database,
java.util.List<HostAddress> addresses,
Options options,
HaMode haMode) |
Modifier and Type | Method and Description |
---|---|
static boolean |
acceptsUrl(java.lang.String url)
Tell if mariadb driver accept url string.
|
UrlParser |
auroraPipelineQuirks()
Permit to set parameters not forced.
|
java.lang.Object |
clone() |
private static void |
defineUrlParserParameters(UrlParser urlParser,
java.util.Properties properties,
java.lang.String hostAddressesString,
java.lang.String additionalParameters)
Sets the parameters of the UrlParser instance: addresses, database and options.
|
boolean |
equals(java.lang.Object parser) |
java.lang.String |
getDatabase() |
HaMode |
getHaMode() |
java.util.List<HostAddress> |
getHostAddresses() |
java.lang.String |
getInitialUrl() |
Options |
getOptions() |
java.lang.String |
getPassword() |
java.lang.String |
getUsername() |
int |
hashCode() |
boolean |
isAurora()
Detection of Aurora.
|
boolean |
isMultiMaster() |
private void |
loadMultiMasterValue() |
static UrlParser |
parse(java.lang.String url) |
static UrlParser |
parse(java.lang.String url,
java.util.Properties prop)
Parse url connection string with additional properties.
|
private static HaMode |
parseHaMode(java.lang.String url,
int separator) |
private static void |
parseInternal(UrlParser urlParser,
java.lang.String url,
java.util.Properties properties)
Parses the connection URL in order to set the UrlParser instance with all the information
provided through the URL.
|
void |
parseUrl(java.lang.String url)
Parse url connection string.
|
void |
setDatabase(java.lang.String database) |
private static void |
setDefaultHostAddressType(UrlParser urlParser) |
void |
setHostAddresses(java.util.List<HostAddress> addresses) |
private void |
setInitialUrl() |
void |
setPassword(java.lang.String password) |
protected void |
setProperties(java.lang.String urlParameters) |
void |
setUsername(java.lang.String username) |
java.lang.String |
toString()
ToString implementation.
|
private static final java.lang.String DISABLE_MYSQL_URL
private static final java.util.regex.Pattern URL_PARAMETER
private static final java.util.regex.Pattern AWS_PATTERN
private java.lang.String database
private Options options
private java.util.List<HostAddress> addresses
private HaMode haMode
private java.lang.String initialUrl
private boolean multiMaster
private UrlParser()
protected UrlParser(java.lang.String database, java.util.List<HostAddress> addresses, Options options, HaMode haMode)
public static boolean acceptsUrl(java.lang.String url)
url
- url Stringpublic static UrlParser parse(java.lang.String url) throws java.sql.SQLException
java.sql.SQLException
public static UrlParser parse(java.lang.String url, java.util.Properties prop) throws java.sql.SQLException
url
- connection stringprop
- propertiesjava.sql.SQLException
- if parsing exception occurprivate static void parseInternal(UrlParser urlParser, java.lang.String url, java.util.Properties properties) throws java.sql.SQLException
urlParser
- object instance in which all data from the connection url is storedurl
- connection URLproperties
- propertiesjava.sql.SQLException
- if format is incorrectprivate static void defineUrlParserParameters(UrlParser urlParser, java.util.Properties properties, java.lang.String hostAddressesString, java.lang.String additionalParameters)
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 connectionprivate static HaMode parseHaMode(java.lang.String url, int separator)
private static void setDefaultHostAddressType(UrlParser urlParser)
private void setInitialUrl()
public UrlParser auroraPipelineQuirks()
public boolean isAurora()
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.
public void parseUrl(java.lang.String url) throws java.sql.SQLException
url
- connection stringjava.sql.SQLException
- if url format is incorrectpublic java.lang.String getUsername()
public void setUsername(java.lang.String username)
public java.lang.String getPassword()
public void setPassword(java.lang.String password)
public java.lang.String getDatabase()
public void setDatabase(java.lang.String database)
public java.util.List<HostAddress> getHostAddresses()
public void setHostAddresses(java.util.List<HostAddress> addresses)
public Options getOptions()
protected void setProperties(java.lang.String urlParameters)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getInitialUrl()
public HaMode getHaMode()
public boolean equals(java.lang.Object parser)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
private void loadMultiMasterValue()
public boolean isMultiMaster()
public java.lang.Object clone() throws java.lang.CloneNotSupportedException
clone
in class java.lang.Object
java.lang.CloneNotSupportedException