Scriptella - SQLServerException: A result set was generated for update

796 views Asked by At

I am a first-time user of Scriptella, and am really struggling with getting started.

I seem to be running into the same issue on both SQL Server 2012 as well as MySQL. With both, I am able to CREATE tables and INSERT records, but get the following errors when using SELECT statements.

SQL Server using driver mssql-jdbc-8.4.0.jre8.jar (and earlier versions):
Driver exception: com.microsoft.sqlserver.jdbc.SQLServerException: A result set was generated for update.

MYSQL using driver mysql-connector-java-5.1.45.jar: Driver exception: java.sql.SQLException: Can not issue SELECT via executeUpdate() or executeLargeUpdate().

I am unable to figure out if this is an issue with my script or if it is a server configuration issue. I tried to set nocount on and nocount off on sql server, but to no avail.

I tried Scriptella version 1.1 as well as version 1.2, and have the same issue.

I am so stuck on this problem that after years of following stackoverflow.com, I am finally posting my first question here. I would so very much appreciate any help.

Please see below for the script I am using as well as the stacktrace. Thanks.

<!DOCTYPE etl SYSTEM "http://scriptella.org/dtd/etl.dtd">
<etl>
    <properties>
        <include href="etl.properties"/> <!--Load from external properties file-->
    </properties>

    <!-- Connection declarations -->
    <connection driver="$driver" url="$url" user="$user" password="$password" classpath="$classpath"/>

    <!--ETL Queries and Scripts -->
    <script>
        <!-- CREATE TABLE WORKED!
          create table TestDB.dbo.test (
          id int
        );   -->

    <!-- INSERT WORKED!
      insert into TestDB.dbo.test (id) values (1);
    -->

    <!-- BELOW FAILS -->
        select * from TestDB.dbo.GLAccounts
        <script>
          insert into TestDB.dbo.test (id) values (?1);
        </script>
    </script>
</etl>

    etl-scriptsS   java -jar ~/Downloads/scriptella/scriptella-1.1/scriptella.jar my-first-etl.xml
    Aug 12, 2020 8:11:33 AM <WARNING> XML configuration warning in file:/home/user1/workspace/etl-scripts/my-first-etl.xml(28:14): The content of element type "script" must match "(include|dialect|onerror)".
    Aug 12, 2020 8:11:33 AM <INFO> Execution Progress.Initializing properties: 1%
    Aug 12, 2020 8:11:36 AM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
    WARNING: TLSv1 was negotiated. Please update server and client to use TLSv1.2 at minimum.
    Aug 12, 2020 8:11:36 AM <INFO> Execution Progress.Initialized connection JdbcConnection{com.microsoft.sqlserver.jdbc.SQLServerConnection}, Dialect{Microsoft SQL Server 11.00.2218}, properties {}: 5%
    Aug 12, 2020 8:11:36 AM <INFO> Execution Progress./etl/script[1] prepared: 10%
    Aug 12, 2020 8:11:36 AM <INFO> Registered JMX mbean: scriptella:type=etl,url="file:/home/user1/workspace/etl-scripts/my-first-etl.xml"
    Aug 12, 2020 8:11:36 AM <SEVERE> Script /home/user1/workspace/etl-scripts/my-first-etl.xml execution failed.
    Location: /etl/script[1]
    JDBC provider exception: Unable to execute statement
    Error statement: 
    select * from TestDB.dbo.GLAccounts
    Error codes: [null, 0]
    Driver exception: com.microsoft.sqlserver.jdbc.SQLServerException: A result set was generated for update.
    etl-scriptsS   java -jar ~/Downloads/scriptella/scriptella-1.1/scriptella.jar my-first-etl.xml
    Aug 12, 2020 8:20:19 AM <WARNING> XML configuration warning in file:/home/user1/workspace/etl-scripts/my-first-etl.xml(28:14): The content of element type "script" must match "(include|dialect|onerror)".
    Aug 12, 2020 8:20:19 AM <INFO> Execution Progress.Initializing properties: 1%
    Aug 12, 2020 8:20:21 AM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
    WARNING: TLSv1 was negotiated. Please update server and client to use TLSv1.2 at minimum.
    Aug 12, 2020 8:20:22 AM <INFO> Execution Progress.Initialized connection JdbcConnection{com.microsoft.sqlserver.jdbc.SQLServerConnection}, Dialect{Microsoft SQL Server 11.00.2218}, properties {}: 5%
    Aug 12, 2020 8:20:22 AM <INFO> Execution Progress./etl/script[1] prepared: 10%
    Aug 12, 2020 8:20:22 AM <INFO> Registered JMX mbean: scriptella:type=etl,url="file:/home/user1/workspace/etl-scripts/my-first-etl.xml"
    Aug 12, 2020 8:20:22 AM <SEVERE> Script /home/user1/workspace/etl-scripts/my-first-etl.xml execution failed.
    Location: /etl/script[1]
    JDBC provider exception: Unable to execute statement
    Error statement: 
    select * from TestDB.dbo.GLAccounts
    Error codes: [null, 0]
    Driver exception: com.microsoft.sqlserver.jdbc.SQLServerException: A result set was generated for update.
    etl-scriptsS    java -jar ~/Downloads/scriptella/scriptella-1.1/scriptella.jar -debug my-first-etl.xml
    Aug 12, 2020 9:30:52 AM <WARNING> XML configuration warning in file:/home/user1/workspace/etl-scripts/my-first-etl.xml(28:14): The content of element type "script" must match "(include|dialect|onerror)".
    Aug 12, 2020 9:30:52 AM <INFO> Execution Progress.Initializing properties: 1%
    Aug 12, 2020 9:30:53 AM <FINE> registerDriver: SQLServerDriver:1
    Aug 12, 2020 9:30:53 AM <FINE> Found driver class com.microsoft.sqlserver.jdbc.SQLServerDriver
    Aug 12, 2020 9:30:53 AM <FINE> DriverManager.getConnection("jdbc:sqlserver://XXX.XXX.XXX.XXX:12345")
    Aug 12, 2020 9:30:53 AM <FINE>     trying com.microsoft.sqlserver.jdbc.SQLServerDriver
    Aug 12, 2020 9:30:54 AM com.microsoft.sqlserver.jdbc.TDSChannel enableSSL
    WARNING: TLSv1 was negotiated. Please update server and client to use TLSv1.2 at minimum.
    Aug 12, 2020 9:30:54 AM <FINE> SQLWarning: reason(TLSv1 was negotiated. Please update server and client to use TLSv1.2 at minimum.)
    Aug 12, 2020 9:30:54 AM <FINE> getConnection returning com.microsoft.sqlserver.jdbc.SQLServerDriver
    Aug 12, 2020 9:30:54 AM <FINE> jdbc:sqlserver://XXX.XXX.XXX.XXX:12345: Statement cache is enabled (cache size 64). Statement separator ';'. Autocommit: false.
    Aug 12, 2020 9:30:54 AM <INFO> Execution Progress.Initialized connection JdbcConnection{com.microsoft.sqlserver.jdbc.SQLServerConnection}, Dialect{Microsoft SQL Server 11.00.2218}, properties {}: 5%
    Aug 12, 2020 9:30:54 AM <INFO> Execution Progress./etl/script[1] prepared: 10%
    Aug 12, 2020 9:30:54 AM <INFO> Registered JMX mbean: scriptella:type=etl,url="file:/home/user1/workspace/etl-scripts/my-first-etl.xml"
    Aug 12, 2020 9:30:54 AM <FINE> Executing script /etl/script[1]
    Aug 12, 2020 9:30:55 AM <FINE> SQLState(null) vendor code(0)
    Aug 12, 2020 9:30:55 AM <FINE> Rolling back JdbcConnection{com.microsoft.sqlserver.jdbc.SQLServerConnection}
    Aug 12, 2020 9:30:55 AM <FINE> Closing JdbcConnection{com.microsoft.sqlserver.jdbc.SQLServerConnection}
    Aug 12, 2020 9:30:55 AM <SEVERE> Script /home/user1/workspace/etl-scripts/my-first-etl.xml execution failed.
    Location: /etl/script[1]
    JDBC provider exception: Unable to execute statement
    Error statement: 
    select * from TestDB.dbo.GLAccounts
    Error codes: [null, 0]
    Driver exception: com.microsoft.sqlserver.jdbc.SQLServerException: A result set was generated for update.
    ---------------Debug Stack Trace-----------------
    scriptella.core.ExceptionInterceptor$ExecutionException: /etl/script[1] failed: Unable to execute statement
        at scriptella.core.ExceptionInterceptor.execute(ExceptionInterceptor.java:44)
        at scriptella.core.Session.execute(Session.java:103)
        at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:227)
        at scriptella.execution.EtlExecutor.execute(EtlExecutor.java:183)
        at scriptella.tools.launcher.EtlLauncher.execute(EtlLauncher.java:276)
        at scriptella.tools.launcher.EtlLauncher.launch(EtlLauncher.java:193)
        at scriptella.tools.launcher.EtlLauncher.main(EtlLauncher.java:321)
    Caused by: scriptella.jdbc.JdbcException: Unable to execute statement. Error statement: 
    select * from TestDB.dbo.GLAccounts. Error codes: [null, 0]
        at scriptella.jdbc.SqlExecutor.statementParsed(SqlExecutor.java:140)
        at scriptella.jdbc.SqlParserBase.handleStatement(SqlParserBase.java:129)
        at scriptella.jdbc.SqlParserBase.parse(SqlParserBase.java:72)
        at scriptella.jdbc.SqlExecutor.execute(SqlExecutor.java:85)
        at scriptella.jdbc.SqlExecutor.execute(SqlExecutor.java:63)
        at scriptella.jdbc.JdbcConnection.executeScript(JdbcConnection.java:211)
        at scriptella.core.ScriptExecutor.execute(ScriptExecutor.java:49)
        at scriptella.core.ContentExecutor.execute(ContentExecutor.java:73)
        at scriptella.core.ElementInterceptor.executeNext(ElementInterceptor.java:56)
        at scriptella.core.StatisticInterceptor.execute(StatisticInterceptor.java:41)
        at scriptella.core.ElementInterceptor.executeNext(ElementInterceptor.java:56)
        at scriptella.core.ExceptionInterceptor.execute(ExceptionInterceptor.java:39)
        ... 6 more
    Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: A result set was generated for update.
        at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:234)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.doExecuteStatement(SQLServerStatement.java:886)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement$StmtExecCmd.doExecute(SQLServerStatement.java:767)
        at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7375)
        at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:3200)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:247)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:222)
        at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeUpdate(SQLServerStatement.java:710)
        at scriptella.jdbc.StatementWrapper$Simple.update(StatementWrapper.java:167)
        at scriptella.jdbc.SqlExecutor.statementParsed(SqlExecutor.java:130)
    ... 17 more

1

There are 1 answers

0
abawb On

The issue was with my script. The corrected script below worked fine ...

<!DOCTYPE etl SYSTEM "http://scriptella.org/dtd/etl.dtd">
<etl>
    <description>Scriptella ETL File Template.</description>
    <properties>
        <include href="etl.properties"/> <!--Load from external properties file-->
    </properties>
    <!-- Connection declarations -->
    <connection driver="$driver" url="$url" user="$user" password="$password" classpath="$classpath"/>

    <!--ETL Queries and Scripts -->
    <query>
        select * from TestDB.dbo.GLAccounts;
        <script>
          insert into TestDB.dbo.test (id) values (?1);
        </script>
    </query>
</etl>