@Test public void testFixSQLCase() throws Exception { String sql = "SELECT \"ID\" FROM TABLE"; String fix = JDBCUtils.changeCaseExcludeQuotes(sql, false); assertEquals(fix, "select \"ID\" from table"); }
public static String changeCaseExcludeQuotes(String s, boolean upper) { List<String> keepList = getWordsBetweenQuotes(s); String tmpStr = upper ? s.toUpperCase() : s.toLowerCase(); for (String word : keepList) { String tmpWord = upper ? word.toUpperCase() : word.toLowerCase(); for (int i = 0; i < QUOTES.length; i++) { String quote = QUOTES[i]; tmpStr = StringUtils.replace(tmpStr, quote + tmpWord + quote, quote + word + quote); } } return tmpStr; }
JDBCUtils { public static String changeCaseExcludeQuotes(String s, boolean upper) { List<String> keepList = getWordsBetweenQuotes(s); String tmpStr = upper ? s.toUpperCase() : s.toLowerCase(); for (String word : keepList) { String tmpWord = upper ? word.toUpperCase() : word.toLowerCase(); for (int i = 0; i < QUOTES.length; i++) { String quote = QUOTES[i]; tmpStr = StringUtils.replace(tmpStr, quote + tmpWord + quote, quote + word + quote); } } return tmpStr; } }
JDBCUtils { public static String changeCaseExcludeQuotes(String s, boolean upper) { List<String> keepList = getWordsBetweenQuotes(s); String tmpStr = upper ? s.toUpperCase() : s.toLowerCase(); for (String word : keepList) { String tmpWord = upper ? word.toUpperCase() : word.toLowerCase(); for (int i = 0; i < QUOTES.length; i++) { String quote = QUOTES[i]; tmpStr = StringUtils.replace(tmpStr, quote + tmpWord + quote, quote + word + quote); } } return tmpStr; }  }
JDBCUtils { public static String changeCaseExcludeQuotes(String s, boolean upper) { List<String> keepList = getWordsBetweenQuotes(s); String tmpStr = upper ? s.toUpperCase() : s.toLowerCase(); for (String word : keepList) { String tmpWord = upper ? word.toUpperCase() : word.toLowerCase(); for (int i = 0; i < QUOTES.length; i++) { String quote = QUOTES[i]; tmpStr = StringUtils.replace(tmpStr, quote + tmpWord + quote, quote + word + quote); } } return tmpStr; }  static List<SQLDataSourceDef> listDatasourceDefs(); static void execute(Connection connection, String sql); static T metadata(Connection connection, String sql, Function<ResultSetMetaData, T> callback); static ResultSetHandler executeQuery(Connection connection, String sql); static Dialect dialect(Connection connection); static Dialect dialect(String url, int majorVersion); static Dialect dialect(String dbName); static List<Column> getColumns(ResultSet resultSet, String[] exclude); static String fixCase(Connection connection, String id); static List<String> getWordsBetweenQuotes(String s); static String changeCaseExcludeQuotes(String s, boolean upper); static ColumnType calculateType(int sqlDataType); static String clobToString(Clob value); }
JDBCUtils { public static String changeCaseExcludeQuotes(String s, boolean upper) { List<String> keepList = getWordsBetweenQuotes(s); String tmpStr = upper ? s.toUpperCase() : s.toLowerCase(); for (String word : keepList) { String tmpWord = upper ? word.toUpperCase() : word.toLowerCase(); for (int i = 0; i < QUOTES.length; i++) { String quote = QUOTES[i]; tmpStr = StringUtils.replace(tmpStr, quote + tmpWord + quote, quote + word + quote); } } return tmpStr; }  static List<SQLDataSourceDef> listDatasourceDefs(); static void execute(Connection connection, String sql); static T metadata(Connection connection, String sql, Function<ResultSetMetaData, T> callback); static ResultSetHandler executeQuery(Connection connection, String sql); static Dialect dialect(Connection connection); static Dialect dialect(String url, int majorVersion); static Dialect dialect(String dbName); static List<Column> getColumns(ResultSet resultSet, String[] exclude); static String fixCase(Connection connection, String id); static List<String> getWordsBetweenQuotes(String s); static String changeCaseExcludeQuotes(String s, boolean upper); static ColumnType calculateType(int sqlDataType); static String clobToString(Clob value); static final Dialect DEFAULT; static final Dialect H2; static final Dialect MYSQL; static final Dialect POSTGRES; static final Dialect ORACLE; static final Dialect ORACLE_LEGACY; static final Dialect SQLSERVER; static final Dialect DB2; static final Dialect SYBASE_ASE; static final Dialect MONETDB; static final String[] QUOTES; }