use of org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl in project dbeaver by serge-rider.
the class SQLServerUtils method getTableFromQuery.
public static SQLServerTableBase getTableFromQuery(DBCSession session, SQLQuery sqlQuery, SQLServerDataSource dataSource) throws DBException, SQLException {
DBCEntityMetaData singleSource = sqlQuery.getSingleSource();
String catalogName = null;
if (singleSource != null) {
catalogName = singleSource.getCatalogName();
}
Connection original = null;
if (session instanceof JDBCConnectionImpl) {
original = ((JDBCConnectionImpl) session).getOriginal();
}
if (catalogName == null && original != null) {
catalogName = original.getCatalog();
}
if (catalogName != null) {
SQLServerDatabase database = dataSource.getDatabase(catalogName);
String schemaName = null;
if (singleSource != null) {
schemaName = singleSource.getSchemaName();
}
if (schemaName == null && original != null) {
schemaName = original.getSchema();
}
if (database != null && schemaName != null) {
SQLServerSchema schema = database.getSchema(schemaName);
if (schema != null && singleSource != null) {
return schema.getTable(session.getProgressMonitor(), singleSource.getEntityName());
}
}
}
return null;
}
use of org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl in project dbeaver by dbeaver.
the class SQLServerUtils method getTableFromQuery.
public static SQLServerTableBase getTableFromQuery(DBCSession session, SQLQuery sqlQuery, SQLServerDataSource dataSource) throws DBException, SQLException {
DBCEntityMetaData singleSource = sqlQuery.getSingleSource();
String catalogName = null;
if (singleSource != null) {
catalogName = singleSource.getCatalogName();
}
Connection original = null;
if (session instanceof JDBCConnectionImpl) {
original = ((JDBCConnectionImpl) session).getOriginal();
}
if (catalogName == null && original != null) {
catalogName = original.getCatalog();
}
if (catalogName != null) {
SQLServerDatabase database = dataSource.getDatabase(catalogName);
String schemaName = null;
if (singleSource != null) {
schemaName = singleSource.getSchemaName();
}
if (schemaName == null && original != null) {
schemaName = original.getSchema();
}
if (database != null && schemaName != null) {
SQLServerSchema schema = database.getSchema(schemaName);
if (schema != null && singleSource != null) {
return schema.getTable(session.getProgressMonitor(), singleSource.getEntityName());
}
}
}
return null;
}
Aggregations