|
1 | 1 | package net.sourceforge.squirrel_sql.fw.sql.tablenamefind; |
2 | 2 |
|
| 3 | +import java.sql.ResultSet; |
| 4 | +import java.sql.ResultSetMetaData; |
| 5 | +import java.sql.SQLException; |
| 6 | +import java.util.regex.Matcher; |
| 7 | +import java.util.regex.Pattern; |
| 8 | + |
3 | 9 | import net.sourceforge.squirrel_sql.client.session.ISession; |
4 | 10 | import net.sourceforge.squirrel_sql.client.session.action.sqlscript.SQLScriptServices; |
5 | 11 | import net.sourceforge.squirrel_sql.fw.datasetviewer.ColumnDisplayDefinition; |
6 | 12 | import net.sourceforge.squirrel_sql.fw.sql.ITableInfo; |
7 | 13 | import net.sourceforge.squirrel_sql.fw.sql.TableInfo; |
8 | 14 | import net.sourceforge.squirrel_sql.fw.util.StringUtilities; |
9 | 15 |
|
10 | | -import java.sql.ResultSet; |
11 | | -import java.sql.ResultSetMetaData; |
12 | | -import java.sql.SQLException; |
13 | | -import java.util.regex.Matcher; |
14 | | -import java.util.regex.Pattern; |
15 | | - |
16 | 16 | public class TableNameFindService |
17 | 17 | { |
18 | 18 | private static final Pattern FILL_COLUMN_NAME_PATTERN = Pattern.compile(".+:([^:]+):[^:]+$"); |
@@ -56,9 +56,10 @@ private static String _findTableNameInSQL(String sql) |
56 | 56 | } |
57 | 57 |
|
58 | 58 | // Get the table name in its original upper-lower case. |
59 | | - String table = sql.trim().substring(matcher.start(1), matcher.end(1)); |
| 59 | + int matchEnd = Math.min(sql.trim().length(), matcher.end(1)); // Prevents StringIndexOutOfBoundsException when sql contains German sz-Umlaut. |
| 60 | + String table = sql.trim().substring(matcher.start(1), matchEnd); |
60 | 61 |
|
61 | | - String behindTable = ucSql.substring(matcher.end(1)).trim(); |
| 62 | + String behindTable = ucSql.substring(matchEnd).trim(); |
62 | 63 |
|
63 | 64 | SingleTableSqlEnum ret = behindTableAllowsEditing(behindTable); |
64 | 65 |
|
|
0 commit comments