提交 6919c17d 编写于 作者: J jurgen

JDBC stored procedures execution

上级 01fbee85
Procedures execute support (describe params + resultset)
DBeaver features usage model
Extract non-visual part to a separate plugin (preferences + editors)
RSV find/replace action
......
......@@ -829,6 +829,19 @@ public final class DBUtils {
statementType = DBCStatementType.EXEC;
}
*/
if (isExecQuery(session, query)) {
statementType = DBCStatementType.EXEC;
}
return session.prepareStatement(
statementType,
query,
scrollable && session.getDataSource().getInfo().supportsResultSetScroll(),
false,
false);
}
public static boolean isExecQuery(DBCSession session, String query) {
DBPDataSource dataSource = session.getDataSource();
if (dataSource instanceof SQLDataSource) {
// Check for EXEC query
......@@ -837,36 +850,12 @@ public final class DBUtils {
final String queryStart = SQLUtils.getFirstKeyword(query);
for (String keyword : executeKeywords) {
if (keyword.equalsIgnoreCase(queryStart)) {
statementType = DBCStatementType.EXEC;
break;
}
}
}
}
/*
final DBCStatement statement = context.prepareStatement(statementType, query, false, false, false);
if (outParamName != null) {
if (statement instanceof CallableStatement) {
try {
if (outParamName.equals("?")) {
((CallableStatement)statement).registerOutParameter(1, java.sql.Types.OTHER);
} else {
((CallableStatement)statement).registerOutParameter(outParamName, java.sql.Types.OTHER);
return true;
}
} catch (SQLException e) {
throw new DBCException(e);
}
}
}
return statement;
*/
return session.prepareStatement(
statementType,
query,
scrollable && dataSource.getInfo().supportsResultSetScroll(),
false,
false);
return false;
}
public static void fireObjectUpdate(DBSObject object)
......
......@@ -28,6 +28,7 @@ import org.jkiss.dbeaver.model.*;
import org.jkiss.dbeaver.model.exec.*;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCDatabaseMetaData;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCSession;
import org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCCallableStatementImpl;
import org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCConnectionImpl;
import org.jkiss.dbeaver.model.meta.Property;
import org.jkiss.dbeaver.model.runtime.DBRProgressMonitor;
......@@ -38,6 +39,7 @@ import org.jkiss.dbeaver.model.struct.DBSDataSourceContainer;
import org.jkiss.dbeaver.model.struct.DBSDataType;
import org.jkiss.dbeaver.model.struct.DBSObject;
import org.jkiss.dbeaver.model.struct.DBSObjectContainer;
import org.jkiss.dbeaver.model.struct.rdb.DBSProcedure;
import org.jkiss.dbeaver.runtime.RuntimeUtils;
import org.jkiss.utils.CommonUtils;
......@@ -175,40 +177,6 @@ public abstract class JDBCDataSource
}
}
protected boolean isConnectionReadOnlyBroken() {
return false;
}
protected String getConnectionUserName(DBPConnectionConfiguration connectionInfo)
{
return connectionInfo.getUserName();
}
protected String getConnectionUserPassword(DBPConnectionConfiguration connectionInfo)
{
return connectionInfo.getUserPassword();
}
protected Driver getDriverInstance(DBRProgressMonitor monitor)
throws DBException
{
return Driver.class.cast(
container.getDriver().getDriverInstance(
RuntimeUtils.makeContext(monitor)
));
}
/**
* Could be overridden by extenders. May contain any additional connection properties.
* Note: these properties may be overwritten by connection advanced properties.
* @return predefined connection properties
*/
@Nullable
protected Map<String, String> getInternalConnectionProperties()
{
return null;
}
/*
@Override
public JDBCSession openSession(DBRProgressMonitor monitor, DBCExecutionPurpose purpose, String taskTitle)
......@@ -467,6 +435,40 @@ public abstract class JDBCDataSource
/////////////////////////////////////////////////
// Overridable functions
protected boolean isConnectionReadOnlyBroken() {
return false;
}
protected String getConnectionUserName(DBPConnectionConfiguration connectionInfo)
{
return connectionInfo.getUserName();
}
protected String getConnectionUserPassword(DBPConnectionConfiguration connectionInfo)
{
return connectionInfo.getUserPassword();
}
protected Driver getDriverInstance(DBRProgressMonitor monitor)
throws DBException
{
return Driver.class.cast(
container.getDriver().getDriverInstance(
RuntimeUtils.makeContext(monitor)
));
}
/**
* Could be overridden by extenders. May contain any additional connection properties.
* Note: these properties may be overwritten by connection advanced properties.
* @return predefined connection properties
*/
@Nullable
protected Map<String, String> getInternalConnectionProperties()
{
return null;
}
protected DBPDataSourceInfo createDataSourceInfo(JDBCDatabaseMetaData metaData)
{
return new JDBCDataSourceInfo(metaData);
......@@ -477,6 +479,11 @@ public abstract class JDBCDataSource
return new JDBCSQLDialect(this, "JDBC", metaData);
}
public DBSProcedure describeCall(JDBCCallableStatementImpl call) {
String queryString = call.getQueryString();
return null;
}
/////////////////////////////////////////////////
// Error assistance
......@@ -508,4 +515,5 @@ public abstract class JDBCDataSource
}
return null;
}
}
......@@ -26,6 +26,7 @@ import org.jkiss.dbeaver.model.data.DBDValueHandler;
import org.jkiss.dbeaver.model.exec.*;
import org.jkiss.dbeaver.model.exec.jdbc.*;
import org.jkiss.dbeaver.model.impl.AbstractSession;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCException;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCExecutionContext;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCUtils;
......@@ -66,7 +67,7 @@ public class JDBCConnectionImpl extends AbstractSession implements JDBCSession,
}
@Override
public DBPDataSource getDataSource()
public JDBCDataSource getDataSource()
{
return context.getDataSource();
}
......@@ -680,7 +681,9 @@ public class JDBCConnectionImpl extends AbstractSession implements JDBCSession,
if (original == null) {
throw new IllegalArgumentException("Null statement");
}
return new JDBCCallableStatementImpl(this, original, sql, !isLoggingEnabled());
JDBCCallableStatementImpl call = new JDBCCallableStatementImpl(this, original, sql, !isLoggingEnabled());
getDataSource().describeCall(call);
return call;
}
}
......@@ -23,6 +23,9 @@ import org.jkiss.dbeaver.ext.db2.model.DB2DataSource;
import org.jkiss.dbeaver.model.exec.jdbc.JDBCDatabaseMetaData;
import org.jkiss.dbeaver.model.impl.jdbc.JDBCSQLDialect;
import java.util.Collection;
import java.util.Collections;
/**
* DB2 SQL dialect
*
......@@ -46,4 +49,11 @@ public class DB2SQLDialect extends JDBCSQLDialect {
return MultiValueInsertMode.GROUP_ROWS;
}
@NotNull
@Override
public Collection<String> getExecuteKeywords()
{
return Collections.singleton("call");
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册