Mercurial > hg > monetdb-java
comparison src/main/java/org/monetdb/jdbc/MonetConnection.java @ 425:95d15f1d750d
Restructured code (incl removal of duplicate code) for utility functions dq() and sq() which add double or double quotes and add escapes to string values.
author | Martin van Dinther <martin.van.dinther@monetdbsolutions.com> |
---|---|
date | Wed, 03 Feb 2021 17:22:03 +0100 (2021-02-03) |
parents | de2ef68b672f |
children | 0b808a4d4f1f |
comparison
equal
deleted
inserted
replaced
424:709300b32284 | 425:95d15f1d750d |
---|---|
1725 .append(':').append(port) | 1725 .append(':').append(port) |
1726 .append('/').append(database); | 1726 .append('/').append(database); |
1727 if (lang == LANG_MAL) | 1727 if (lang == LANG_MAL) |
1728 sb.append("?language=mal"); | 1728 sb.append("?language=mal"); |
1729 return sb.toString(); | 1729 return sb.toString(); |
1730 } | |
1731 | |
1732 /** | |
1733 * Utility method to escape all ocurrences of special characters | |
1734 * (double slashes and single quotes) in a string literal | |
1735 * It is called from: MonetDatabaseMetaData and MonetPreparedStatement | |
1736 */ | |
1737 final String escapeSpecialChars(final String in) { | |
1738 String ret = in; | |
1739 if (ret.contains("\\\\")) | |
1740 // all double slashes in input need to be escaped. | |
1741 ret = ret.replaceAll("\\\\", "\\\\\\\\"); | |
1742 if (ret.contains("'")) | |
1743 // all single quotes in input need to be escaped. | |
1744 ret = ret.replaceAll("'", "\\\\'"); | |
1745 return ret; | |
1746 } | 1730 } |
1747 | 1731 |
1748 | 1732 |
1749 // Internal caches for 3 static mserver environment values, so they aren't queried from mserver again and again | 1733 // Internal caches for 3 static mserver environment values, so they aren't queried from mserver again and again |
1750 private String env_current_user; | 1734 private String env_current_user; |