Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
import com.genexus.common.interfaces.IClientPreferences;
import com.genexus.common.interfaces.IExtensionApplication;
import com.genexus.common.interfaces.IPreferences;
import com.genexus.db.DBConnectionManager;
import com.genexus.db.Namespace;
import com.genexus.db.*;
import com.genexus.internet.HttpResponse;
import com.genexus.util.IniFile;
import com.genexus.wrapper.GXCollectionWrapper;
Expand Down Expand Up @@ -97,6 +96,10 @@ public boolean handlSQLException(int handle, String dataSource, SQLException ex)
return com.genexus.Application.getConnectionManager().getDataSource(handle, dataSource).dbms.ObjectNotFound(ex);
}

@Override
public void handleSQLError(IErrorHandler errorHandler, SQLException e, ModelContext context, int remoteHandle, AbstractGXConnection conn, String datastoreName, Cursor cursor) {
}

@Override
public Class getModelContextClass() {
return ModelContext.class;
Expand Down
25 changes: 22 additions & 3 deletions common/src/main/java/com/genexus/ExecuteDirectSQL.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@

import java.sql.SQLException;

import com.genexus.ModelContext;
import com.genexus.common.classes.AbstractGXConnection;
import com.genexus.common.interfaces.SpecificImplementation;
import com.genexus.db.*;
import com.genexus.util.*;

public class ExecuteDirectSQL
{
public static void execute(ModelContext context, int handle, String dataSource, String Statement)
{
execute(context, handle, dataSource, Statement, null);
}

public static void execute(ModelContext context, int handle, String dataSource, String statement, IErrorHandler errorHandler)
{
try
{
SpecificImplementation.Application.executeStatement(context, handle, dataSource, Statement);
SpecificImplementation.Application.executeStatement(context, handle, dataSource, statement);
}
catch (SQLException ex)
{
Expand All @@ -27,7 +32,21 @@ public static void execute(ModelContext context, int handle, String dataSource,
}
else
{
SpecificImplementation.Application.GXLocalException(handle, "ExecuteDirectSQL/" + Statement, ex);
if (errorHandler == null)
{
SpecificImplementation.Application.GXLocalException(handle, "ExecuteDirectSQL/" + statement, ex);
}
else
{
try {
AbstractGXConnection conn = new DefaultConnectionProvider().getConnection(context, handle, dataSource, true, true);
SpecificImplementation.Application.handleSQLError(errorHandler, ex, context, handle, conn, dataSource, new DirectStatement(statement));
}
catch (SQLException e) {
throw new GXRuntimeException(e);
}
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package com.genexus.common.interfaces;

import java.sql.SQLException;
import com.genexus.GXDBException;
import com.genexus.ICleanedup;
import com.genexus.ModelContext;
import com.genexus.SdtMessages_Message;

import com.genexus.*;
import com.genexus.common.classes.AbstractGXConnection;
import com.genexus.ModelContext;
import com.genexus.common.classes.AbstractNamespace;
import com.genexus.common.classes.AbstractUserInformation;

import com.genexus.db.Cursor;
import com.genexus.util.IniFile;

public interface IExtensionApplication {
Expand Down Expand Up @@ -43,6 +42,8 @@ public interface IExtensionApplication {

boolean handlSQLException(int handle, String dataSource, SQLException ex);

void handleSQLError(IErrorHandler errorHandler, SQLException e, ModelContext context, int remoteHandle, AbstractGXConnection conn, String datastoreName, Cursor cursor);

Class<?> getModelContextClass();

ModelContext createModelContext(Class<SdtMessages_Message> class1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.genexus.GXRuntimeException;
import com.genexus.IErrorHandler;
import com.genexus.ModelContext;
import com.genexus.common.classes.AbstractGXConnection;
import com.genexus.db.driver.GXDBMS;
import com.genexus.util.ReorgSubmitThreadPool;

Expand All @@ -22,7 +23,16 @@ public class DefaultExceptionErrorHandler

public static void handleSQLError(IErrorHandler errorHandler, SQLException e, ModelContext context, int remoteHandle, IDataStoreHelper helper, Cursor cursor)
{
cursor.status = mapErrorToStatus(DBConnectionManager.getInstance().getUserInformation(remoteHandle).getNamespace().getDataSource(helper.getDataStoreName()).dbms, e);
try {
AbstractGXConnection conn = helper.getConnectionProvider().getConnection(context, remoteHandle, helper.getDataStoreName(), true, true);
handleSQLError1(errorHandler, e, context, remoteHandle, conn, helper.getDataStoreName(), cursor);
}
catch (SQLException exc) {}
}

public static void handleSQLError1(IErrorHandler errorHandler, SQLException e, ModelContext context, int remoteHandle, AbstractGXConnection conn, String datastoreName, Cursor cursor)
{
cursor.status = mapErrorToStatus(DBConnectionManager.getInstance().getUserInformation(remoteHandle).getNamespace().getDataSource(datastoreName).dbms, e);
if (cursor.status != Cursor.DUPLICATE)
{
ReorgSubmitThreadPool.setAnError();
Expand All @@ -48,16 +58,13 @@ public static void handleSQLError(IErrorHandler errorHandler, SQLException e, Mo

if (context.globals.Gx_eop == ERROPT_DEFAULT)
{
defaultSQLErrorHandler(errorHandler, e, context, remoteHandle, helper, cursor);
defaultSQLErrorHandler(context, cursor);
}

if (context.globals.Gx_eop == ERROPT_CANCEL)
{
com.genexus.Application.rollback(context, remoteHandle, helper.getDataStoreName(), null);
try {
helper.getConnectionProvider().getConnection(context, remoteHandle, helper.getDataStoreName(), true, true).setError();
}
catch (SQLException exc) {}
com.genexus.Application.rollback(context, remoteHandle, datastoreName, null);
conn.setError();
throw new GXRuntimeException(e);
}
}
Expand Down Expand Up @@ -101,7 +108,7 @@ private static int mapErrorToStatus(GXDBMS dbms, SQLException e)
return Cursor.UNEXPECTED_DBMS_ERROR;
}

public static void defaultSQLErrorHandler(IErrorHandler errorHandler, SQLException e, ModelContext context, int remoteHandle, IDataStoreHelper helper, Cursor cursor)
public static void defaultSQLErrorHandler(ModelContext context, Cursor cursor)
{
context.globals.Gx_eop = ERROPT_CANCEL;

Expand Down
9 changes: 7 additions & 2 deletions java/src/main/java/com/genexus/specific/java/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import com.genexus.common.interfaces.IClientPreferences;
import com.genexus.common.interfaces.IExtensionApplication;
import com.genexus.common.interfaces.IPreferences;
import com.genexus.db.DBConnectionManager;
import com.genexus.db.Namespace;
import com.genexus.db.*;
import com.genexus.db.Cursor;
import com.genexus.internet.HttpResponse;
import com.genexus.util.IniFile;
import com.genexus.webpanels.GXWebObjectStub;
Expand Down Expand Up @@ -98,6 +98,11 @@ public boolean handlSQLException(int handle, String dataSource, SQLException ex)
return com.genexus.Application.getConnectionManager().getDataSource(handle, dataSource).dbms.ObjectNotFound(ex);
}

@Override
public void handleSQLError(IErrorHandler errorHandler, SQLException e, ModelContext context, int remoteHandle, AbstractGXConnection conn, String datastoreName, Cursor cursor) {
DefaultExceptionErrorHandler.handleSQLError1(errorHandler, e, context, remoteHandle, conn, datastoreName, cursor);
}

@Override
public Class getModelContextClass() {
return ModelContext.class;
Expand Down