comparison src/main/java/nl/cwi/monetdb/jdbc/MonetConnection.java @ 370:2ab474af487c

Add utility method to replace calls to x.replaceAll().replaceAll() in several places.
author Martin van Dinther <martin.van.dinther@monetdbsolutions.com>
date Thu, 17 Sep 2020 17:33:49 +0200 (2020-09-17)
parents 54137aeb1f92
children ffdc7b0e102d
comparison
equal deleted inserted replaced
369:aa2e5d8c5047 370:2ab474af487c
1638 } 1638 }
1639 1639
1640 //== end methods of interface java.sql.Connection 1640 //== end methods of interface java.sql.Connection
1641 1641
1642 1642
1643 //== internal helper methods which do not belong to the JDBC interface
1644
1643 /** 1645 /**
1644 * @return whether the JDBC BLOB type should be mapped to VARBINARY type. 1646 * @return whether the JDBC BLOB type should be mapped to VARBINARY type.
1645 * This allows generic JDBC programs to fetch Blob data via getBytes() 1647 * This allows generic JDBC programs to fetch Blob data via getBytes()
1646 * instead of getBlob() and Blob.getBinaryStream() to reduce overhead. 1648 * instead of getBlob() and Blob.getBinaryStream() to reduce overhead.
1647 * It is called from: MonetResultSet and MonetPreparedStatement 1649 * It is called from: MonetResultSet and MonetPreparedStatement
1680 .append('/').append(database); 1682 .append('/').append(database);
1681 if (lang == LANG_MAL) 1683 if (lang == LANG_MAL)
1682 sb.append("?language=mal"); 1684 sb.append("?language=mal");
1683 return sb.toString(); 1685 return sb.toString();
1684 } 1686 }
1687
1688 /**
1689 * Utility method to escape all ocurrences of special characters
1690 * (double slashes and single quotes) in a string literal
1691 * It is called from: MonetDatabaseMetaData and MonetPreparedStatement
1692 */
1693 final String escapeSpecialChars(final String in) {
1694 String ret = in;
1695 if (ret.contains("\\\\"))
1696 // all double slashes in input need to be escaped.
1697 ret = ret.replaceAll("\\\\", "\\\\\\\\");
1698 if (ret.contains("'"))
1699 // all single quotes in input need to be escaped.
1700 ret = ret.replaceAll("'", "\\\\'");
1701 return ret;
1702 }
1703
1685 1704
1686 // Internal cache for 3 static mserver environment values, so they aren't queried from mserver again and again 1705 // Internal cache for 3 static mserver environment values, so they aren't queried from mserver again and again
1687 private String env_current_user = null; 1706 private String env_current_user = null;
1688 private String env_monet_version = null; 1707 private String env_monet_version = null;
1689 private String env_max_clients = null; 1708 private String env_max_clients = null;