提交 53c8e8bf 编写于 作者: J jurgen

JDBC API validation

Former-commit-id: edadae07
上级 387fe837
quick-search in navigator tree
Data transfer DECIMAL(x,y) types convert.
Extract non-visual part to a separate plugin
RSV find/replace action
Vertica keywords
......
......@@ -75,6 +75,9 @@ public class JDBCExecutionContext implements DBCExecutionContext, DBCTransaction
ACTIVE_CONTEXT.set(this);
try {
this.connection = dataSource.openConnection(monitor, purpose);
if (this.connection == null) {
throw new DBCException("Null connection returned");
}
if (autoCommit != null) {
try {
......@@ -103,7 +106,7 @@ public class JDBCExecutionContext implements DBCExecutionContext, DBCTransaction
QMUtils.getDefaultHandler().handleContextOpen(this, !this.autoCommit);
// Copy context state
dataSource.initializeContextState(monitor, this, !primaryContext || forceActiveObject);
this.dataSource.initializeContextState(monitor, this, !primaryContext || forceActiveObject);
// Add self to context list
this.dataSource.allContexts.add(this);
......@@ -112,7 +115,7 @@ public class JDBCExecutionContext implements DBCExecutionContext, DBCTransaction
}
}
public Connection getConnection(DBRProgressMonitor monitor) throws SQLException
public @NotNull Connection getConnection(DBRProgressMonitor monitor) throws SQLException
{
if (connection == null) {
try {
......
......@@ -17,6 +17,7 @@
*/
package org.jkiss.dbeaver.model.impl.jdbc.exec;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCCallableStatement;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
......@@ -37,8 +38,8 @@ import java.util.Map;
public class JDBCCallableStatementImpl extends JDBCPreparedStatementImpl implements JDBCCallableStatement {
public JDBCCallableStatementImpl(
JDBCSession connection,
CallableStatement original,
@NotNull JDBCSession connection,
@NotNull CallableStatement original,
@Nullable String query,
boolean disableLogging)
{
......
......@@ -116,18 +116,30 @@ public class JDBCConnectionImpl extends AbstractSession implements JDBCSession,
// (e.g. in Oracle it parses IN/OUT parameters)
JDBCStatement statement;
try {
statement = createStatement(
scrollable ? ResultSet.TYPE_SCROLL_INSENSITIVE : ResultSet.TYPE_FORWARD_ONLY,
updatable ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY);
}
catch (UnsupportedOperationException e) {
statement = createStatement();
}
catch (IncompatibleClassChangeError e) {
statement = createStatement();
}
if (statement instanceof JDBCStatementImpl) {
((JDBCStatementImpl)statement).setQueryString(sqlQuery);
try {
statement = createStatement(
scrollable ? ResultSet.TYPE_SCROLL_INSENSITIVE : ResultSet.TYPE_FORWARD_ONLY,
updatable ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY);
}
catch (UnsupportedOperationException e) {
statement = createStatement();
}
catch (LinkageError e) {
statement = createStatement();
}
if (statement instanceof JDBCStatementImpl) {
((JDBCStatementImpl)statement).setQueryString(sqlQuery);
}
} catch (IllegalArgumentException e) {
log.warn(e);
try {
statement = prepareStatement(
sqlQuery,
scrollable ? ResultSet.TYPE_SCROLL_INSENSITIVE : ResultSet.TYPE_FORWARD_ONLY,
updatable ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY);
} catch (SQLException e1) {
statement = prepareStatement(sqlQuery);
}
}
return statement;
} else if (returnGeneratedKeys) {
......@@ -348,8 +360,7 @@ public class JDBCConnectionImpl extends AbstractSession implements JDBCSession,
public JDBCStatement createStatement(int resultSetType, int resultSetConcurrency)
throws SQLException
{
return createStatementImpl(
getOriginal().createStatement(resultSetType, resultSetConcurrency));
return createStatementImpl(getOriginal().createStatement(resultSetType, resultSetConcurrency));
}
@Override
......@@ -646,20 +657,29 @@ public class JDBCConnectionImpl extends AbstractSession implements JDBCSession,
}
protected JDBCStatement createStatementImpl(Statement original)
throws SQLFeatureNotSupportedException
throws SQLFeatureNotSupportedException,IllegalArgumentException
{
if (original == null) {
throw new IllegalArgumentException("Null statement");
}
return new JDBCStatementImpl<Statement>(this, original, !isLoggingEnabled());
}
protected JDBCPreparedStatement createPreparedStatementImpl(PreparedStatement original, @Nullable String sql)
throws SQLFeatureNotSupportedException
throws SQLFeatureNotSupportedException,IllegalArgumentException
{
if (original == null) {
throw new IllegalArgumentException("Null statement");
}
return new JDBCPreparedStatementImpl(this, original, sql, !isLoggingEnabled());
}
protected JDBCCallableStatement createCallableStatementImpl(CallableStatement original, @Nullable String sql)
throws SQLFeatureNotSupportedException
throws SQLFeatureNotSupportedException,IllegalArgumentException
{
if (original == null) {
throw new IllegalArgumentException("Null statement");
}
return new JDBCCallableStatementImpl(this, original, sql, !isLoggingEnabled());
}
......
......@@ -17,6 +17,7 @@
*/
package org.jkiss.dbeaver.model.impl.jdbc.exec;
import org.jkiss.code.NotNull;
import org.jkiss.code.Nullable;
import org.jkiss.dbeaver.model.exec.DBCException;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement;
......@@ -38,8 +39,8 @@ import java.util.Calendar;
public class JDBCPreparedStatementImpl extends JDBCStatementImpl<PreparedStatement> implements JDBCPreparedStatement {
public JDBCPreparedStatementImpl(
JDBCSession connection,
PreparedStatement original,
@NotNull JDBCSession connection,
@NotNull PreparedStatement original,
String query,
boolean disableLogging)
{
......
......@@ -55,7 +55,7 @@ public class JDBCStatementImpl<STATEMENT extends Statement> implements JDBCState
private boolean disableLogging;
public JDBCStatementImpl(JDBCSession connection, STATEMENT original, boolean disableLogging)
public JDBCStatementImpl(@NotNull JDBCSession connection, @NotNull STATEMENT original, boolean disableLogging)
{
this.connection = connection;
this.original = original;
......
......@@ -41,17 +41,6 @@ import org.jkiss.utils.ArrayUtils;
public class DataSourceConnectHandler extends DataSourceHandler
{
@Nullable
@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
final DataSourceDescriptor dataSourceContainer = (DataSourceDescriptor) getDataSourceContainer(event, false);
if (dataSourceContainer != null) {
execute(null, dataSourceContainer, null);
}
return null;
}
/**
* Connects datasource
* @param monitor progress monitor or null. If nul then new job will be started
......@@ -155,6 +144,17 @@ public class DataSourceConnectHandler extends DataSourceHandler
}
}
@Nullable
@Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
final DataSourceDescriptor dataSourceContainer = (DataSourceDescriptor) getDataSourceContainer(event, false);
if (dataSourceContainer != null) {
execute(null, dataSourceContainer, null);
}
return null;
}
private static void updateDataSourceObject(DataSourceDescriptor dataSourceDescriptor)
{
dataSourceDescriptor.getRegistry().fireDataSourceEvent(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册