コード例 #1
0
 /**
  * Parse url connection string.
  *
  * @param url connection string
  * @throws SQLException if url format is incorrect
  */
 public void parseUrl(String url) throws SQLException {
   if (url.startsWith("jdbc:mysql:")) {
     parseInternal(this, url, new Properties());
     return;
   }
   String[] arr = new String[] {"jdbc:mysql:thin:", "jdbc:mariadb:"};
   for (String prefix : arr) {
     if (url.startsWith(prefix)) {
       parseInternal(this, url, new Properties());
       break;
     }
   }
 }
コード例 #2
0
 /**
  * Parse url connection string with additional properties.
  *
  * @param url connection string
  * @param prop properties
  * @return UrlParser instance
  * @throws SQLException if parsing exception occur
  */
 public static UrlParser parse(final String url, Properties prop) throws SQLException {
   if (url != null) {
     if (prop == null) {
       prop = new Properties();
     }
     if (url.startsWith("jdbc:mysql:")) {
       UrlParser urlParser = new UrlParser();
       parseInternal(urlParser, url, prop);
       return urlParser;
     } else {
       if (url.startsWith("jdbc:mariadb:")) {
         UrlParser urlParser = new UrlParser();
         parseInternal(urlParser, "jdbc:mysql:" + url.substring(12), prop);
         return urlParser;
       }
     }
   }
   return null;
 }