@@ -84,6 +84,27 @@ public void getTables() throws SQLException {
8484 rs .close ();
8585 }
8686
87+ @ Test
88+ public void getTablesWithEscape () throws SQLException {
89+ stat .executeUpdate ("create table 'table%with%wildcards'(c1 integer)" );
90+ stat .executeUpdate ("create table 'table_with_wildcards'(c2 integer)" );
91+ stat .executeUpdate ("create table 'tableXwithXwildcards'(c3 integer)" );
92+
93+ String esc = meta .getSearchStringEscape ();
94+ try (ResultSet rs =
95+ meta .getTables (null , null , "table_with_wildcards" .replace ("_" , esc + "_" ), null )) {
96+ assertThat (rs .next ()).isTrue ();
97+ assertThat (rs .getString ("TABLE_NAME" )).isEqualTo ("table_with_wildcards" );
98+ assertThat (rs .next ()).isFalse ();
99+ }
100+ try (ResultSet rs =
101+ meta .getTables (null , null , "table%with%wildcards" .replace ("%" , esc + "%" ), null )) {
102+ assertThat (rs .next ()).isTrue ();
103+ assertThat (rs .getString ("TABLE_NAME" )).isEqualTo ("table%with%wildcards" );
104+ assertThat (rs .next ()).isFalse ();
105+ }
106+ }
107+
87108 @ Test
88109 public void getTableTypes () throws SQLException {
89110 ResultSet rs = meta .getTableTypes ();
@@ -271,6 +292,25 @@ public void getColumnsIncludingGenerated() throws SQLException {
271292 assertThat (rs .next ()).isFalse ();
272293 }
273294
295+ @ Test
296+ public void getColumnsWithEscape () throws SQLException {
297+ stat .executeUpdate ("create table wildcard(col1 integer, co_1 integer, 'co%1' integer)" );
298+
299+ String esc = meta .getSearchStringEscape ();
300+ try (ResultSet rs =
301+ meta .getColumns (null , null , "wildcard" , "co_1" .replace ("_" , esc + "_" ))) {
302+ assertThat (rs .next ()).isTrue ();
303+ assertThat (rs .getString ("COLUMN_NAME" )).isEqualTo ("co_1" );
304+ assertThat (rs .next ()).isFalse ();
305+ }
306+ try (ResultSet rs =
307+ meta .getColumns (null , null , "wildcard" , "co%1" .replace ("%" , esc + "%" ))) {
308+ assertThat (rs .next ()).isTrue ();
309+ assertThat (rs .getString ("COLUMN_NAME" )).isEqualTo ("co%1" );
310+ assertThat (rs .next ()).isFalse ();
311+ }
312+ }
313+
274314 @ Test
275315 public void numberOfgetImportedKeysCols () throws SQLException {
276316
0 commit comments