Class UrlParser
- All Implemented Interfaces:
Cloneable
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|replica))][(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.
example : 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=replica)(host=replica1)/database?user=greg&password=pass
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanacceptsUrl(String url) Tell if mariadb driver accept url string.Permit setting parameters not forced.clone()booleaninthashCode()booleanstatic UrlParserstatic UrlParserparse(String url, Properties prop) Parse url connection string with additional properties.voidParse url connection string.voidsetDatabase(String database) voidsetPassword(String password) protected voidsetProperties(String urlParameters) voidsetUsername(String username) toString()ToString implementation.
-
Constructor Details
-
UrlParser
public UrlParser(String database, List<HostAddress> addresses, Options options, HaMode haMode) throws SQLException Constructor.- Parameters:
database- databaseaddresses- list of hostsoptions- connection optionhaMode- High availability mode- Throws:
SQLException- if credential plugin cannot be loaded
-
-
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
-
auroraPipelineQuirks
Permit setting 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
-
parseUrl
Parse url connection string.- Parameters:
url- connection string- Throws:
SQLException- if url format is incorrect
-
getUsername
-
setUsername
-
getPassword
-
setPassword
-
getDatabase
-
setDatabase
-
getHostAddresses
-
getOptions
-
setProperties
-
getCredentialPlugin
-
toString
-
getInitialUrl
-
getHaMode
-
equals
-
hashCode
-
isMultiMaster
public boolean isMultiMaster() -
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-