Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
18788098
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
18788098
编写于
12月 26, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#7472 Default catalogs/schema connection config
上级
1543bdd4
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
95 addition
and
19 deletion
+95
-19
plugins/org.jkiss.dbeaver.ext.db2/src/org/jkiss/dbeaver/ext/db2/model/DB2ExecutionContext.java
.../org/jkiss/dbeaver/ext/db2/model/DB2ExecutionContext.java
+14
-2
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/model/ExasolExecutionContext.java
...kiss/dbeaver/ext/exasol/model/ExasolExecutionContext.java
+14
-2
plugins/org.jkiss.dbeaver.ext.generic/src/org/jkiss/dbeaver/ext/generic/model/GenericExecutionContext.java
...ss/dbeaver/ext/generic/model/GenericExecutionContext.java
+22
-9
plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/model/SQLServerExecutionContext.java
...ss/dbeaver/ext/mssql/model/SQLServerExecutionContext.java
+16
-2
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLExecutionContext.java
.../jkiss/dbeaver/ext/mysql/model/MySQLExecutionContext.java
+15
-2
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/model/OracleExecutionContext.java
...kiss/dbeaver/ext/oracle/model/OracleExecutionContext.java
+14
-2
未找到文件。
plugins/org.jkiss.dbeaver.ext.db2/src/org/jkiss/dbeaver/ext/db2/model/DB2ExecutionContext.java
浏览文件 @
18788098
...
@@ -21,6 +21,7 @@ import org.jkiss.code.Nullable;
...
@@ -21,6 +21,7 @@ import org.jkiss.code.Nullable;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionBootstrap
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
...
@@ -31,6 +32,7 @@ import org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance;
...
@@ -31,6 +32,7 @@ import org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSCatalog
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSCatalog
;
import
org.jkiss.utils.CommonUtils
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
...
@@ -108,6 +110,12 @@ public class DB2ExecutionContext extends JDBCExecutionContext implements DBCExec
...
@@ -108,6 +110,12 @@ public class DB2ExecutionContext extends JDBCExecutionContext implements DBCExec
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
// Check default active schema
// Check default active schema
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
META
,
"Query active schema"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
META
,
"Query active schema"
))
{
if
(
useBootstrapSettings
)
{
DBPConnectionBootstrap
bootstrap
=
getBootstrapSettings
();
if
(!
CommonUtils
.
isEmpty
(
bootstrap
.
getDefaultSchemaName
()))
{
setCurrentSchema
(
monitor
,
bootstrap
.
getDefaultSchemaName
());
}
}
// Get active schema
// Get active schema
this
.
activeSchemaName
=
determineActiveSchema
(
session
);
this
.
activeSchemaName
=
determineActiveSchema
(
session
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -122,9 +130,13 @@ public class DB2ExecutionContext extends JDBCExecutionContext implements DBCExec
...
@@ -122,9 +130,13 @@ public class DB2ExecutionContext extends JDBCExecutionContext implements DBCExec
log
.
debug
(
"Null current schema"
);
log
.
debug
(
"Null current schema"
);
return
;
return
;
}
}
setCurrentSchema
(
monitor
,
object
.
getName
());
}
private
void
setCurrentSchema
(
DBRProgressMonitor
monitor
,
String
schemaName
)
throws
DBCException
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active schema"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active schema"
))
{
JDBCUtils
.
executeSQL
(
session
,
String
.
format
(
SET_CURRENT_SCHEMA
,
object
.
getName
()
));
JDBCUtils
.
executeSQL
(
session
,
String
.
format
(
SET_CURRENT_SCHEMA
,
schemaName
));
this
.
activeSchemaName
=
object
.
getName
()
;
this
.
activeSchemaName
=
schemaName
;
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
DBCException
(
e
,
getDataSource
());
throw
new
DBCException
(
e
,
getDataSource
());
}
}
...
...
plugins/org.jkiss.dbeaver.ext.exasol/src/org/jkiss/dbeaver/ext/exasol/model/ExasolExecutionContext.java
浏览文件 @
18788098
...
@@ -21,6 +21,7 @@ import org.jkiss.code.Nullable;
...
@@ -21,6 +21,7 @@ import org.jkiss.code.Nullable;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionBootstrap
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
...
@@ -31,6 +32,7 @@ import org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance;
...
@@ -31,6 +32,7 @@ import org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSCatalog
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSCatalog
;
import
org.jkiss.utils.CommonUtils
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
...
@@ -107,6 +109,12 @@ public class ExasolExecutionContext extends JDBCExecutionContext implements DBCE
...
@@ -107,6 +109,12 @@ public class ExasolExecutionContext extends JDBCExecutionContext implements DBCE
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
// Check default active schema
// Check default active schema
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
META
,
"Query active schema"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
META
,
"Query active schema"
))
{
if
(
useBootstrapSettings
)
{
DBPConnectionBootstrap
bootstrap
=
getBootstrapSettings
();
if
(!
CommonUtils
.
isEmpty
(
bootstrap
.
getDefaultSchemaName
()))
{
setCurrentSchema
(
monitor
,
bootstrap
.
getDefaultSchemaName
());
}
}
// Get active schema
// Get active schema
this
.
activeSchemaName
=
determineActiveSchema
(
session
);
this
.
activeSchemaName
=
determineActiveSchema
(
session
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -121,9 +129,13 @@ public class ExasolExecutionContext extends JDBCExecutionContext implements DBCE
...
@@ -121,9 +129,13 @@ public class ExasolExecutionContext extends JDBCExecutionContext implements DBCE
log
.
debug
(
"Null current schema"
);
log
.
debug
(
"Null current schema"
);
return
;
return
;
}
}
setCurrentSchema
(
monitor
,
object
.
getName
());
}
private
void
setCurrentSchema
(
DBRProgressMonitor
monitor
,
String
schemaName
)
throws
DBCException
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active schema"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active schema"
))
{
JDBCUtils
.
executeSQL
(
session
,
String
.
format
(
SET_CURRENT_SCHEMA
,
object
.
getName
()
));
JDBCUtils
.
executeSQL
(
session
,
String
.
format
(
SET_CURRENT_SCHEMA
,
schemaName
));
this
.
activeSchemaName
=
object
.
getName
()
;
this
.
activeSchemaName
=
schemaName
;
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
DBCException
(
e
,
getDataSource
());
throw
new
DBCException
(
e
,
getDataSource
());
}
}
...
...
plugins/org.jkiss.dbeaver.ext.generic/src/org/jkiss/dbeaver/ext/generic/model/GenericExecutionContext.java
浏览文件 @
18788098
...
@@ -22,6 +22,7 @@ import org.jkiss.dbeaver.DBException;
...
@@ -22,6 +22,7 @@ import org.jkiss.dbeaver.DBException;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ext.generic.GenericConstants
;
import
org.jkiss.dbeaver.ext.generic.GenericConstants
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionBootstrap
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
...
@@ -257,16 +258,26 @@ public class GenericExecutionContext extends JDBCExecutionContext implements DBC
...
@@ -257,16 +258,26 @@ public class GenericExecutionContext extends JDBCExecutionContext implements DBC
return
;
return
;
}
}
GenericDataSource
dataSource
=
getDataSource
();
GenericSchema
oldSelectedSchema
=
getDefaultSchema
();
GenericSchema
oldSelectedSchema
=
getDefaultSchema
();
setDefaultSchema
(
monitor
,
schema
.
getName
());
if
(
oldSelectedSchema
!=
null
)
{
DBUtils
.
fireObjectSelect
(
oldSelectedSchema
,
false
);
}
DBUtils
.
fireObjectSelect
(
schema
,
true
);
}
private
void
setDefaultSchema
(
DBRProgressMonitor
monitor
,
String
schemaName
)
throws
DBCException
{
GenericDataSource
dataSource
=
getDataSource
();
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active schema"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active schema"
))
{
if
(
dataSource
.
isSelectedEntityFromAPI
())
{
if
(
dataSource
.
isSelectedEntityFromAPI
())
{
session
.
setSchema
(
schema
.
getName
()
);
session
.
setSchema
(
schema
Name
);
}
else
{
}
else
{
if
(
CommonUtils
.
isEmpty
(
dataSource
.
getQuerySetActiveDB
()))
{
if
(
CommonUtils
.
isEmpty
(
dataSource
.
getQuerySetActiveDB
()))
{
throw
new
DBCException
(
"Active schema can't be changed for this kind of datasource!"
);
throw
new
DBCException
(
"Active schema can't be changed for this kind of datasource!"
);
}
}
String
changeQuery
=
dataSource
.
getQuerySetActiveDB
().
replaceFirst
(
"\\?"
,
Matcher
.
quoteReplacement
(
schema
.
getName
()
));
String
changeQuery
=
dataSource
.
getQuerySetActiveDB
().
replaceFirst
(
"\\?"
,
Matcher
.
quoteReplacement
(
schema
Name
));
try
(
JDBCPreparedStatement
dbStat
=
session
.
prepareStatement
(
changeQuery
))
{
try
(
JDBCPreparedStatement
dbStat
=
session
.
prepareStatement
(
changeQuery
))
{
dbStat
.
execute
();
dbStat
.
execute
();
}
}
...
@@ -274,18 +285,20 @@ public class GenericExecutionContext extends JDBCExecutionContext implements DBC
...
@@ -274,18 +285,20 @@ public class GenericExecutionContext extends JDBCExecutionContext implements DBC
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
DBCException
(
e
,
dataSource
);
throw
new
DBCException
(
e
,
dataSource
);
}
}
selectedEntityName
=
schema
.
getName
()
;
selectedEntityName
=
schema
Name
;
dataSource
.
setSelectedEntityType
(
GenericConstants
.
ENTITY_TYPE_SCHEMA
);
dataSource
.
setSelectedEntityType
(
GenericConstants
.
ENTITY_TYPE_SCHEMA
);
if
(
oldSelectedSchema
!=
null
)
{
DBUtils
.
fireObjectSelect
(
oldSelectedSchema
,
false
);
}
DBUtils
.
fireObjectSelect
(
schema
,
true
);
}
}
@Override
@Override
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
if
(
useBootstrapSettings
)
{
DBPConnectionBootstrap
bootstrap
=
getBootstrapSettings
();
if
(!
CommonUtils
.
isEmpty
(
bootstrap
.
getDefaultSchemaName
()))
{
setDefaultSchema
(
monitor
,
bootstrap
.
getDefaultSchemaName
());
}
}
String
oldEntityName
=
selectedEntityName
;
String
oldEntityName
=
selectedEntityName
;
DBSObject
oldDefaultObject
=
getDefaultObject
();
DBSObject
oldDefaultObject
=
getDefaultObject
();
...
...
plugins/org.jkiss.dbeaver.ext.mssql/src/org/jkiss/dbeaver/ext/mssql/model/SQLServerExecutionContext.java
浏览文件 @
18788098
...
@@ -23,6 +23,7 @@ import org.jkiss.dbeaver.Log;
...
@@ -23,6 +23,7 @@ import org.jkiss.dbeaver.Log;
import
org.jkiss.dbeaver.ext.mssql.SQLServerConstants
;
import
org.jkiss.dbeaver.ext.mssql.SQLServerConstants
;
import
org.jkiss.dbeaver.ext.mssql.SQLServerUtils
;
import
org.jkiss.dbeaver.ext.mssql.SQLServerUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionBootstrap
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
...
@@ -31,6 +32,7 @@ import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
...
@@ -31,6 +32,7 @@ import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.utils.CommonUtils
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
...
@@ -114,6 +116,13 @@ public class SQLServerExecutionContext extends JDBCExecutionContext implements D
...
@@ -114,6 +116,13 @@ public class SQLServerExecutionContext extends JDBCExecutionContext implements D
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
// Check default active schema
// Check default active schema
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
META
,
"Query active database"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
META
,
"Query active database"
))
{
if
(
useBootstrapSettings
)
{
DBPConnectionBootstrap
bootstrap
=
getBootstrapSettings
();
if
(!
CommonUtils
.
isEmpty
(
bootstrap
.
getDefaultSchemaName
()))
{
setCurrentDatabase
(
monitor
,
bootstrap
.
getDefaultCatalogName
());
}
}
activeDatabaseName
=
SQLServerUtils
.
getCurrentDatabase
(
session
);
activeDatabaseName
=
SQLServerUtils
.
getCurrentDatabase
(
session
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
DBCException
(
e
,
getDataSource
());
throw
new
DBCException
(
e
,
getDataSource
());
...
@@ -127,9 +136,14 @@ public class SQLServerExecutionContext extends JDBCExecutionContext implements D
...
@@ -127,9 +136,14 @@ public class SQLServerExecutionContext extends JDBCExecutionContext implements D
log
.
debug
(
"Null current schema"
);
log
.
debug
(
"Null current schema"
);
return
false
;
return
false
;
}
}
String
databaseName
=
object
.
getName
();
return
setCurrentDatabase
(
monitor
,
databaseName
);
}
private
boolean
setCurrentDatabase
(
DBRProgressMonitor
monitor
,
String
databaseName
)
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active database"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active database"
))
{
SQLServerUtils
.
setCurrentDatabase
(
session
,
object
.
getName
()
);
SQLServerUtils
.
setCurrentDatabase
(
session
,
databaseName
);
activeDatabaseName
=
object
.
getName
()
;
activeDatabaseName
=
databaseName
;
return
true
;
return
true
;
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
log
.
error
(
e
);
log
.
error
(
e
);
...
...
plugins/org.jkiss.dbeaver.ext.mysql/src/org/jkiss/dbeaver/ext/mysql/model/MySQLExecutionContext.java
浏览文件 @
18788098
...
@@ -22,6 +22,7 @@ import org.jkiss.dbeaver.DBException;
...
@@ -22,6 +22,7 @@ import org.jkiss.dbeaver.DBException;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.ext.mysql.MySQLUtils
;
import
org.jkiss.dbeaver.ext.mysql.MySQLUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionBootstrap
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
...
@@ -110,6 +111,13 @@ public class MySQLExecutionContext extends JDBCExecutionContext implements DBCEx
...
@@ -110,6 +111,13 @@ public class MySQLExecutionContext extends JDBCExecutionContext implements DBCEx
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
// Check default active schema
// Check default active schema
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
META
,
"Query active database"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
META
,
"Query active database"
))
{
if
(
useBootstrapSettings
)
{
DBPConnectionBootstrap
bootstrap
=
getBootstrapSettings
();
if
(!
CommonUtils
.
isEmpty
(
bootstrap
.
getDefaultCatalogName
()))
{
setCurrentDatabaseName
(
monitor
,
bootstrap
.
getDefaultCatalogName
());
}
}
activeDatabaseName
=
MySQLUtils
.
determineCurrentDatabase
(
session
);
activeDatabaseName
=
MySQLUtils
.
determineCurrentDatabase
(
session
);
}
catch
(
DBException
e
)
{
}
catch
(
DBException
e
)
{
throw
new
DBCException
(
e
,
getDataSource
());
throw
new
DBCException
(
e
,
getDataSource
());
...
@@ -123,11 +131,16 @@ public class MySQLExecutionContext extends JDBCExecutionContext implements DBCEx
...
@@ -123,11 +131,16 @@ public class MySQLExecutionContext extends JDBCExecutionContext implements DBCEx
log
.
debug
(
"Null current database"
);
log
.
debug
(
"Null current database"
);
return
false
;
return
false
;
}
}
String
databaseName
=
object
.
getName
();
return
setCurrentDatabaseName
(
monitor
,
databaseName
);
}
private
boolean
setCurrentDatabaseName
(
DBRProgressMonitor
monitor
,
String
databaseName
)
throws
DBCException
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active catalog"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active catalog"
))
{
try
(
JDBCPreparedStatement
dbStat
=
session
.
prepareStatement
(
"use "
+
DBUtils
.
getQuotedIdentifier
(
object
)))
{
try
(
JDBCPreparedStatement
dbStat
=
session
.
prepareStatement
(
"use "
+
DBUtils
.
getQuotedIdentifier
(
getDataSource
(),
databaseName
)))
{
dbStat
.
execute
();
dbStat
.
execute
();
}
}
this
.
activeDatabaseName
=
object
.
getName
()
;
this
.
activeDatabaseName
=
databaseName
;
return
true
;
return
true
;
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
DBCException
(
e
,
getDataSource
());
throw
new
DBCException
(
e
,
getDataSource
());
...
...
plugins/org.jkiss.dbeaver.ext.oracle/src/org/jkiss/dbeaver/ext/oracle/model/OracleExecutionContext.java
浏览文件 @
18788098
...
@@ -21,6 +21,7 @@ import org.jkiss.code.Nullable;
...
@@ -21,6 +21,7 @@ import org.jkiss.code.Nullable;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.DBUtils
;
import
org.jkiss.dbeaver.model.connection.DBPConnectionBootstrap
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionContextDefaults
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
import
org.jkiss.dbeaver.model.exec.DBCExecutionPurpose
;
...
@@ -30,6 +31,7 @@ import org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext;
...
@@ -30,6 +31,7 @@ import org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance
;
import
org.jkiss.dbeaver.model.impl.jdbc.JDBCRemoteInstance
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.DBRProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSCatalog
;
import
org.jkiss.dbeaver.model.struct.rdb.DBSCatalog
;
import
org.jkiss.utils.CommonUtils
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
...
@@ -103,6 +105,12 @@ public class OracleExecutionContext extends JDBCExecutionContext implements DBCE
...
@@ -103,6 +105,12 @@ public class OracleExecutionContext extends JDBCExecutionContext implements DBCE
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
public
boolean
refreshDefaults
(
DBRProgressMonitor
monitor
,
boolean
useBootstrapSettings
)
throws
DBException
{
// Check default active schema
// Check default active schema
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
META
,
"Query active schema"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
META
,
"Query active schema"
))
{
if
(
useBootstrapSettings
)
{
DBPConnectionBootstrap
bootstrap
=
getBootstrapSettings
();
if
(!
CommonUtils
.
isEmpty
(
bootstrap
.
getDefaultSchemaName
()))
{
setCurrentSchema
(
monitor
,
bootstrap
.
getDefaultSchemaName
());
}
}
// Get active schema
// Get active schema
this
.
activeSchemaName
=
OracleUtils
.
getCurrentSchema
(
session
);
this
.
activeSchemaName
=
OracleUtils
.
getCurrentSchema
(
session
);
if
(
this
.
activeSchemaName
!=
null
)
{
if
(
this
.
activeSchemaName
!=
null
)
{
...
@@ -122,9 +130,13 @@ public class OracleExecutionContext extends JDBCExecutionContext implements DBCE
...
@@ -122,9 +130,13 @@ public class OracleExecutionContext extends JDBCExecutionContext implements DBCE
log
.
debug
(
"Null current schema"
);
log
.
debug
(
"Null current schema"
);
return
;
return
;
}
}
setCurrentSchema
(
monitor
,
object
.
getName
());
}
private
void
setCurrentSchema
(
DBRProgressMonitor
monitor
,
String
activeSchemaName
)
throws
DBCException
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active schema"
))
{
try
(
JDBCSession
session
=
openSession
(
monitor
,
DBCExecutionPurpose
.
UTIL
,
"Set active schema"
))
{
OracleUtils
.
setCurrentSchema
(
session
,
object
.
getName
()
);
OracleUtils
.
setCurrentSchema
(
session
,
activeSchemaName
);
this
.
activeSchemaName
=
object
.
getName
()
;
this
.
activeSchemaName
=
activeSchemaName
;
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
throw
new
DBCException
(
e
,
getDataSource
());
throw
new
DBCException
(
e
,
getDataSource
());
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录