use of java.sql.SQLWarning in project jOOQ by jOOQ.
the class FieldsImpl method field0.
private final <U> U field0(String fieldName, FieldOrIndex<U> result) {
if (fieldName == null)
return result.resultNull();
Field<?> columnMatch = null;
int indexMatch = -1;
for (int i = 0; i < fields.length; i++) {
Field<?> f = fields[i];
if (f.getName().equals(fieldName)) {
if (columnMatch == null) {
columnMatch = f;
indexMatch = i;
} else // [#4476] [#4477] [#5046] This might be unintentional from a user
// perspective, e.g. when ambiguous ID columns are present.
{
log.info("Ambiguous match found for " + fieldName + ". Both " + columnMatch + " and " + f + " match.", new SQLWarning());
}
}
}
return result.result(columnMatch, indexMatch);
}
use of java.sql.SQLWarning in project jOOQ by jOOQ.
the class FieldsImpl method field0.
private final <U> U field0(Field<?> field, FieldOrIndex<U> result) {
if (field == null)
return result.resultNull();
// [#4540] Try finding a match by identity
for (int i = 0; i < fields.length; i++) {
Field<?> f = fields[i];
if (f == field)
return result.result(f, i);
}
// [#1802] Try finding an exact match (e.g. exact matching qualified name)
for (int i = 0; i < fields.length; i++) {
Field<?> f = fields[i];
if (f.equals(field))
return result.result(f, i);
}
// [#4283] table / column matches are better than only column matches
Field<?> columnMatch = null;
Field<?> columnMatch2 = null;
int indexMatch = -1;
String tableName = tableName(field);
String fieldName = field.getName();
for (int i = 0; i < fields.length; i++) {
Field<?> f = fields[i];
String fName = f.getName();
if (tableName != null) {
String tName = tableName(f);
if (tName != null && tableName.equals(tName) && fName.equals(fieldName))
return result.result(f, i);
}
// In case no exact match was found, return the first field with matching name
if (fName.equals(fieldName)) {
if (columnMatch == null) {
columnMatch = f;
indexMatch = i;
} else // [#4476] [#4477] This might be unintentional from a user
// perspective, e.g. when ambiguous ID columns are present.
// [#5578] Finish the loop, though, as we might have an exact match
// despite some ambiguity
{
columnMatch2 = f;
}
}
}
if (columnMatch2 != null)
if (log.isInfoEnabled())
log.info("Ambiguous match found for " + fieldName + ". Both " + columnMatch + " and " + columnMatch2 + " match.", new SQLWarning());
return result.result(columnMatch, indexMatch);
}
use of java.sql.SQLWarning in project dbeaver by serge-rider.
the class PostgreToolWithStatus method getExecuteStatistics.
@Override
public List<ToolStatus> getExecuteStatistics(OBJECT_TYPE object, SETTINGS settings, DBEPersistAction action, DBCSession session, DBCStatement dbStat) throws DBCException {
List<ToolStatus> statusList = new ArrayList<>();
try {
int warnNum = 0;
SQLWarning warning = ((JDBCStatement) dbStat).getWarnings();
while (warning != null) {
statusList.add(new ToolStatus(object, warning.getMessage()));
warnNum++;
warning = warning.getNextWarning();
}
if (warnNum == 0) {
statusList.add(new ToolStatus(object, "Done"));
}
} catch (SQLException e) {
// ignore
}
return statusList;
}
use of java.sql.SQLWarning in project dbeaver by serge-rider.
the class DB2ToolWithStatus method getExecuteStatistics.
@Override
public List<ToolStatus> getExecuteStatistics(OBJECT_TYPE object, SETTINGS settings, DBEPersistAction action, DBCSession session, DBCStatement dbStat) throws DBCException {
List<ToolStatus> statusList = new ArrayList<>();
try {
int warnNum = 0;
SQLWarning warning = ((JDBCStatement) dbStat).getWarnings();
while (warning != null) {
statusList.add(new ToolStatus(object, warning.getMessage()));
warnNum++;
warning = warning.getNextWarning();
}
if (warnNum == 0) {
// $NON-NLS-1$
statusList.add(new ToolStatus(object, "Done"));
}
} catch (SQLException e) {
// ignore
}
return statusList;
}
use of java.sql.SQLWarning in project dbeaver by serge-rider.
the class SQLServerToolWithStatus method getExecuteStatistics.
@Override
public List<ToolStatus> getExecuteStatistics(OBJECT_TYPE object, SETTINGS settings, DBEPersistAction action, DBCSession session, DBCStatement dbStat) throws DBCException {
List<ToolStatus> statusList = new ArrayList<>();
try {
int warnNum = 0;
SQLWarning warning = ((JDBCStatement) dbStat).getWarnings();
while (warning != null) {
statusList.add(new ToolStatus(object, warning.getMessage()));
warnNum++;
warning = warning.getNextWarning();
}
if (warnNum == 0) {
statusList.add(new ToolStatus(object, "Done"));
}
} catch (SQLException e) {
// ignore
}
return statusList;
}
Aggregations