0

I got an error after running a scala script in a db2 powered spark-shell. I can't find much information about the error online and wanted to know if there was a way to do that.

I have tried executing the getNextException() method on the exception and it was not a recognized command.

I have tried running a part of the java code listed as an example at https://www.ibm.com/support/knowledgecenter/SSEPGG_11.1.0/com.ibm.db2.luw.apdv.java.doc/src/tpc/imjcc_tjvjdbue.html and similar values were not recognized.

scala> try {
     |   //Load data into necessary table
     |   loadNMCview.write.format("jdbc").option("url", s"${sf_url}").option("dbtable", "tableName").option("driver", "com.ibm.db2.jcc.DB2Driver").mode("append").save
     | } catch(BatchUpdateException buex) {
     |     System.err.println("Contents of BatchUpdateException:")
     |     System.err.println(" Update counts: ")
     |     System.out.println(buex.getUpdateCounts())
     |   }
 <console>:31: error: not found: value BatchUpdateException
        } catch(BatchUpdateException buex) {
                ^ <console>:34: error: not found: value buex
            System.out.println(buex.getUpdateCounts())

Code:

loadNMCview.write.format("jdbc").option("url", s"${sf_url}").option("dbtable", "schemaName.tableName").option("driver", "com.ibm.db2.jcc.DB2Driver").mode("append").save

Error:

20/07/06 13:37:20 WARN TaskSetManager: Lost task 0.0 in stage 0.0 (TID 0, edclhdpd138.bcbsfl.com, executor 2): com.ibm.db2.jcc.am.BatchUpdateException: [jcc][t4][102][10040][4.17.29] Batch failure. The batch was submitted, but at least one exception occurred on an individual member of the batch. Use getNextException() to retrieve the exceptions for specific batched elements. ERRORCODE=-4229, SQLSTATE=null

Matt
  • 113
  • 1
  • 1
  • 5
  • You call the `getNextException()` method of the exception that you're handling. This is the only way to retrieve the nested exception. – mustaccio Jul 07 '20 at 15:50
  • calling com.ibm.db2.jcc.am.BatchUpdateException.getNextException() returns "error: not found: value BatchUpdateException" BatchUpdateException.getNextException() returns " error: value getNextException is not a member of object com.ibm.db2.jcc.am.BatchUpdateException" – Matt Jul 08 '20 at 13:03
  • I immediately tried BatchUpdateException.getUpdateCounts which is the first instruction in the link. the result is error: not found: value BatchUpdateException. I think this might have something to do with the fact that I'm executing commands on spark-shell but not db2 directly? – Matt Jul 08 '20 at 14:44
  • OP edited to include code of the exception handler. – Matt Jul 08 '20 at 17:16
  • Try variations on `catch { case e: java.sql.BatchUpdateException => throw e.getNextException } ` . Apart from exception handling, A jdbc trace may also show more details (see Db2 Knowledge Center for details of enabling jdbc trace). Also the Db2-server may (if suitably configured) show the details of the exception in its diagnostics , so you can ask for help from your DBA if you have one, or depending on the (unstated) platform of the Db2-server (and your access level) you can query its diagnostics with SQL. – mao Jul 08 '20 at 17:35
  • What is your Db2-server platform (Z/os , i series , linux/unix/windows/cloud) ? – mao Jul 29 '20 at 15:25
  • My Db2 server platform is Linux – Matt Jul 30 '20 at 15:58

0 Answers0