public class JDBCUrl extends Object
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:mysql://[2001:0660:7401:0200:0000:0000:0edf:bdd7]:3306
Some examples :
jdbc:mysql://localhost:3306/database?user=greg&password=pass
jdbc:mysql://address=(type=master)(host=master1),address=(port=3307)(type=slave)(host=slave1)/database?user=greg&password=pass
| Modifier | Constructor and Description |
|---|---|
protected |
JDBCUrl(String database,
List<HostAddress> addresses,
Options options,
UrlHAMode haMode) |
| Modifier and Type | Method and Description |
|---|---|
String |
getDatabase() |
UrlHAMode |
getHaMode() |
List<HostAddress> |
getHostAddresses() |
Options |
getOptions() |
String |
getPassword() |
String |
getUsername() |
static JDBCUrl |
parse(String url) |
static JDBCUrl |
parse(String url,
Properties prop) |
void |
parseUrl(String url) |
protected void |
setDatabase(String database) |
protected void |
setPassword(String password) |
protected void |
setProperties(String urlParameters) |
protected void |
setUsername(String username) |
String |
toString() |
protected JDBCUrl(String database, List<HostAddress> addresses, Options options, UrlHAMode haMode) throws SQLException
SQLExceptionpublic static JDBCUrl parse(String url) throws SQLException
SQLExceptionpublic static JDBCUrl parse(String url, Properties prop) throws SQLException
SQLExceptionpublic void parseUrl(String url) throws SQLException
SQLExceptionpublic String getUsername()
protected void setUsername(String username)
public String getPassword()
protected void setPassword(String password)
public String getDatabase()
protected void setDatabase(String database)
public List<HostAddress> getHostAddresses()
public Options getOptions()
protected void setProperties(String urlParameters)
public UrlHAMode getHaMode()
Copyright © 2015. All rights reserved.