提交 880d7dd2 编写于 作者: J jurgen

JDBC connections init fixed. Active object set.

Former-commit-id: f79468d3
上级 3f1606ee
......@@ -72,8 +72,8 @@ public abstract class JDBCDataSource
throws DBException
{
this.container = container;
this.executionContext = new JDBCExecutionContext(this, "Main", true);
this.executionContext.connect(monitor);
this.executionContext = new JDBCExecutionContext(this, "Main");
this.executionContext.connect(monitor, null, null, false);
}
protected Connection openConnection(DBRProgressMonitor monitor, String purpose)
......@@ -208,8 +208,8 @@ public abstract class JDBCDataSource
@Override
public DBCExecutionContext openIsolatedContext(@NotNull DBRProgressMonitor monitor, @NotNull String purpose) throws DBException
{
JDBCExecutionContext context = new JDBCExecutionContext(this, purpose, false);
context.connect(monitor);
JDBCExecutionContext context = new JDBCExecutionContext(this, purpose);
context.connect(monitor, null, null, true);
return context;
}
......@@ -266,7 +266,7 @@ public abstract class JDBCDataSource
{
if (!isEmbeddedDataSource() && container.getPreferenceStore().getBoolean(DBeaverPreferences.META_SEPARATE_CONNECTION)) {
synchronized (this) {
this.metaContext = new JDBCExecutionContext(this, "Metadata", true);
this.metaContext = new JDBCExecutionContext(this, "Metadata");
this.metaContext.connect(monitor, true, null, false);
}
}
......
......@@ -20,11 +20,9 @@ package org.jkiss.dbeaver.model.impl.jdbc;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.DBException;
import org.jkiss.dbeaver.DBeaverPreferences;
import org.jkiss.dbeaver.core.CoreMessages;
import org.jkiss.dbeaver.core.Log;
import org.jkiss.dbeaver.model.DBPDataSource;
import org.jkiss.dbeaver.model.DBPPreferenceStore;
import org.jkiss.dbeaver.model.DBPTransactionIsolation;
import org.jkiss.dbeaver.model.exec.*;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
......@@ -46,17 +44,15 @@ public class JDBCExecutionContext implements DBCExecutionContext, DBCTransaction
@NotNull
private final JDBCDataSource dataSource;
private final boolean primaryContext;
private volatile Connection connection;
private final String purpose;
private volatile Boolean autoCommit;
private volatile Integer transactionIsolationLevel;
public JDBCExecutionContext(@NotNull JDBCDataSource dataSource, String purpose, boolean primary)
public JDBCExecutionContext(@NotNull JDBCDataSource dataSource, String purpose)
{
this.dataSource = dataSource;
this.purpose = purpose;
this.primaryContext = primary;
}
private Connection getConnection() {
......@@ -97,7 +93,7 @@ public class JDBCExecutionContext implements DBCExecutionContext, DBCTransaction
log.warn("Can't set auto-commit state", e); //$NON-NLS-1$
}
if (txnLevel != null) {
if (!this.autoCommit && txnLevel != null) {
try {
connection.setTransactionIsolation(txnLevel);
this.transactionIsolationLevel = txnLevel;
......@@ -116,7 +112,7 @@ public class JDBCExecutionContext implements DBCExecutionContext, DBCTransaction
QMUtils.getDefaultHandler().handleContextOpen(this, !this.autoCommit);
// Copy context state
this.dataSource.initializeContextState(monitor, this, !primaryContext || forceActiveObject);
this.dataSource.initializeContextState(monitor, this, forceActiveObject);
// Add self to context list
this.dataSource.allContexts.add(this);
......
......@@ -77,6 +77,8 @@ public interface DBSDataSourceContainer extends DBSObject, DBDPreferences
void setDefaultTransactionsIsolation(DBPTransactionIsolation isolationLevel);
String getDefaultActiveObject();
/**
* Search for object filter which corresponds specified object type and parent object.
* Search filter which match any super class or interface implemented by specified type.
......
......@@ -394,6 +394,7 @@ public class DataSourceDescriptor
}
}
@Override
public String getDefaultActiveObject() {
return preferenceStore.getString(DBeaverPreferences.DEFAULT_ACTIVE_OBJECT);
}
......@@ -637,7 +638,7 @@ public class DataSourceDescriptor
dataSource.initialize(monitor);
// Change connection properties
prepareContext(monitor);
initConnectionState(monitor);
}
connectFailed = false;
......@@ -675,7 +676,7 @@ public class DataSourceDescriptor
}
}
private void prepareContext(DBRProgressMonitor monitor) throws DBException {
private void initConnectionState(DBRProgressMonitor monitor) throws DBException {
if (dataSource == null) {
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册