Review Board 1.7.22


SQOOP-1043 Sqoop2: Improve error messages in Derby repository

Review Request #11072 - Created May 12, 2013 and submitted

Jarek Cecho
SQOOP-1043
Reviewers
Sqoop
sqoop-sqoop2
I've added simple method that will print out arbitrary amount of objects.
Both unit and integration tests seems to be passing. In addition I've verified the functionality on real issue.
repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
Revision e4f6562 New Change
[20] 348 lines
[+20] [+] public MConnector findConnector(String shortName, Connection conn) {
349

    
   
349

   
350
      if (rsetBaseConnector.next()) {
350
      if (rsetBaseConnector.next()) {
351
        throw new SqoopException(DerbyRepoError.DERBYREPO_0005, shortName);
351
        throw new SqoopException(DerbyRepoError.DERBYREPO_0005, shortName);
352
      }
352
      }
353
    } catch (SQLException ex) {
353
    } catch (SQLException ex) {

    
   
354
      logException(ex, shortName);
354
      throw new SqoopException(DerbyRepoError.DERBYREPO_0004, shortName, ex);
355
      throw new SqoopException(DerbyRepoError.DERBYREPO_0004, shortName, ex);
355
    } finally {
356
    } finally {
356
      closeStatements(baseConnectorFetchStmt,
357
      closeStatements(baseConnectorFetchStmt,
357
        formFetchStmt, inputFetchStmt);
358
        formFetchStmt, inputFetchStmt);
358
    }
359
    }
[+20] [20] 32 lines
[+20] [+] public void registerFramework(MFramework mf, Connection conn) {
391

    
   
392

   
392
      // We're using hardcoded value for framework metadata as they are
393
      // We're using hardcoded value for framework metadata as they are
393
      // represented as NULL in the database.
394
      // represented as NULL in the database.
394
      mf.setPersistenceId(1);
395
      mf.setPersistenceId(1);
395
    } catch (SQLException ex) {
396
    } catch (SQLException ex) {
396
      throw new SqoopException(DerbyRepoError.DERBYREPO_0014,
397
      logException(ex, mf);
397
          mf.toString(), ex);
398
      throw new SqoopException(DerbyRepoError.DERBYREPO_0014, ex);
398
    } finally {
399
    } finally {
399
      closeStatements(baseFormStmt, baseInputStmt);
400
      closeStatements(baseFormStmt, baseInputStmt);
400
    }
401
    }
401
  }
402
  }
402

    
   
403

   
[+20] [20] 101 lines
[+20] [+] public void createConnection(MConnection connection, Connection conn) {
504
        conn);
505
        conn);
505

    
   
506

   
506
      connection.setPersistenceId(connectionId);
507
      connection.setPersistenceId(connectionId);
507

    
   
508

   
508
    } catch (SQLException ex) {
509
    } catch (SQLException ex) {

    
   
510
      logException(ex, connection);
509
      throw new SqoopException(DerbyRepoError.DERBYREPO_0019, ex);
511
      throw new SqoopException(DerbyRepoError.DERBYREPO_0019, ex);
510
    } finally {
512
    } finally {
511
      closeStatements(stmt);
513
      closeStatements(stmt);
512
    }
514
    }
513
  }
515
  }
[+20] [20] 28 lines
[+20] [+] public void updateConnection(MConnection connection, Connection conn) {
542
        connection.getPersistenceId(),
544
        connection.getPersistenceId(),
543
        connection.getFrameworkPart().getForms(),
545
        connection.getFrameworkPart().getForms(),
544
        conn);
546
        conn);
545

    
   
547

   
546
    } catch (SQLException ex) {
548
    } catch (SQLException ex) {

    
   
549
      logException(ex, connection);
547
      throw new SqoopException(DerbyRepoError.DERBYREPO_0021, ex);
550
      throw new SqoopException(DerbyRepoError.DERBYREPO_0021, ex);
548
    } finally {
551
    } finally {
549
      closeStatements(deleteStmt, updateStmt);
552
      closeStatements(deleteStmt, updateStmt);
550
    }
553
    }
551
  }
554
  }
[+20] [20] 13 lines
[+20] [+] public boolean existsConnection(long id, Connection conn) {
565
      // Should be always valid in query with count
568
      // Should be always valid in query with count
566
      rs.next();
569
      rs.next();
567

    
   
570

   
568
      return rs.getLong(1) == 1;
571
      return rs.getLong(1) == 1;
569
    } catch (SQLException ex) {
572
    } catch (SQLException ex) {

    
   
573
      logException(ex, id);
570
      throw new SqoopException(DerbyRepoError.DERBYREPO_0025, ex);
574
      throw new SqoopException(DerbyRepoError.DERBYREPO_0025, ex);
571
    } finally {
575
    } finally {
572
      closeResultSets(rs);
576
      closeResultSets(rs);
573
      closeStatements(stmt);
577
      closeStatements(stmt);
574
    }
578
    }
[+20] [20] 13 lines
[+20] [+] public boolean inUseConnection(long connectionId, Connection conn) {
588
      rs.next();
592
      rs.next();
589

    
   
593

   
590
      return rs.getLong(1) != 0;
594
      return rs.getLong(1) != 0;
591

    
   
595

   
592
    } catch (SQLException e) {
596
    } catch (SQLException e) {

    
   
597
      logException(e, connectionId);
593
      throw new SqoopException(DerbyRepoError.DERBYREPO_0032, e);
598
      throw new SqoopException(DerbyRepoError.DERBYREPO_0032, e);
594
    } finally {
599
    } finally {
595
      closeResultSets(rs);
600
      closeResultSets(rs);
596
      closeStatements(stmt);
601
      closeStatements(stmt);
597
    }
602
    }
[+20] [20] 10 lines
[+20] [+] public void deleteConnection(long id, Connection conn) {
608
      deleteConnectionInputs(id, conn);
613
      deleteConnectionInputs(id, conn);
609
      dltConn = conn.prepareStatement(STMT_DELETE_CONNECTION);
614
      dltConn = conn.prepareStatement(STMT_DELETE_CONNECTION);
610
      dltConn.setLong(1, id);
615
      dltConn.setLong(1, id);
611
      dltConn.executeUpdate();
616
      dltConn.executeUpdate();
612
    } catch (SQLException ex) {
617
    } catch (SQLException ex) {

    
   
618
      logException(ex, id);
613
      throw new SqoopException(DerbyRepoError.DERBYREPO_0022, ex);
619
      throw new SqoopException(DerbyRepoError.DERBYREPO_0022, ex);
614
    } finally {
620
    } finally {
615
      closeStatements(dltConn);
621
      closeStatements(dltConn);
616
    }
622
    }
617
  }
623
  }
[+20] [20] 7 lines
[+20] [+] public void deleteConnectionInputs(long id, Connection conn) {
625
    try {
631
    try {
626
      dltConnInput = conn.prepareStatement(STMT_DELETE_CONNECTION_INPUT);
632
      dltConnInput = conn.prepareStatement(STMT_DELETE_CONNECTION_INPUT);
627
      dltConnInput.setLong(1, id);
633
      dltConnInput.setLong(1, id);
628
      dltConnInput.executeUpdate();
634
      dltConnInput.executeUpdate();
629
    } catch (SQLException ex) {
635
    } catch (SQLException ex) {

    
   
636
      logException(ex, id);
630
      throw new SqoopException(DerbyRepoError.DERBYREPO_0022, ex);
637
      throw new SqoopException(DerbyRepoError.DERBYREPO_0022, ex);
631
    } finally {
638
    } finally {
632
      closeStatements(dltConnInput);
639
      closeStatements(dltConnInput);
633
    }
640
    }
634
  }
641
  }
[+20] [20] 17 lines
[+20] [+] public MConnection findConnection(long id, Connection conn) {
652

    
   
659

   
653
      // Return the first and only one connection object
660
      // Return the first and only one connection object
654
      return connections.get(0);
661
      return connections.get(0);
655

    
   
662

   
656
    } catch (SQLException ex) {
663
    } catch (SQLException ex) {

    
   
664
      logException(ex, id);
657
      throw new SqoopException(DerbyRepoError.DERBYREPO_0023, ex);
665
      throw new SqoopException(DerbyRepoError.DERBYREPO_0023, ex);
658
    } finally {
666
    } finally {
659
      closeStatements(stmt);
667
      closeStatements(stmt);
660
    }
668
    }
661
  }
669
  }
[+20] [20] 8 lines
[+20] public MConnection findConnection(long id, Connection conn) {
670
      stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_ALL);
678
      stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_ALL);
671

    
   
679

   
672
      return loadConnections(stmt, conn);
680
      return loadConnections(stmt, conn);
673

    
   
681

   
674
    } catch (SQLException ex) {
682
    } catch (SQLException ex) {

    
   
683
      logException(ex);
675
      throw new SqoopException(DerbyRepoError.DERBYREPO_0023, ex);
684
      throw new SqoopException(DerbyRepoError.DERBYREPO_0023, ex);
676
    } finally {
685
    } finally {
677
      closeStatements(stmt);
686
      closeStatements(stmt);
678
    }
687
    }
679
  }
688
  }
680

    
   
689

   
681

    
   
690

   
682
  /**
691
  /**
683
   *
692
   *
684
   * {@inheritDoc}
693
   * {@inheritDoc}
685
   *
694
   *
686
   */
695
   */
687
  @Override
696
  @Override
688
  public List<MConnection> findConnectionsForConnector(long
697
  public List<MConnection> findConnectionsForConnector(long connectorID, Connection conn) {
689
    connectorID, Connection conn) {

   
690
    PreparedStatement stmt = null;
698
    PreparedStatement stmt = null;
691
    try {
699
    try {
692
      stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_FOR_CONNECTOR);
700
      stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_FOR_CONNECTOR);
693
      stmt.setLong(1, connectorID);
701
      stmt.setLong(1, connectorID);
694

    
   
702

   
695
      return loadConnections(stmt, conn);
703
      return loadConnections(stmt, conn);
696

    
   
704

   
697
    } catch (SQLException ex) {
705
    } catch (SQLException ex) {

    
   
706
      logException(ex, connectorID);
698
      throw new SqoopException(DerbyRepoError.DERBYREPO_0023, ex);
707
      throw new SqoopException(DerbyRepoError.DERBYREPO_0023, ex);
699
    } finally {
708
    } finally {
700
      closeStatements(stmt);
709
      closeStatements(stmt);
701
    }
710
    }
702
  }
711
  }
[+20] [20] 22 lines
[+20] [+] public void updateConnector(MConnector mConnector, Connection conn) {
725
      deleteForm.setLong(1, mConnector.getPersistenceId());
734
      deleteForm.setLong(1, mConnector.getPersistenceId());
726
      deleteInput.executeUpdate();
735
      deleteInput.executeUpdate();
727
      deleteForm.executeUpdate();
736
      deleteForm.executeUpdate();
728

    
   
737

   
729
    } catch (SQLException e) {
738
    } catch (SQLException e) {

    
   
739
      logException(e, mConnector);
730
      throw new SqoopException(DerbyRepoError.DERBYREPO_0038, e);
740
      throw new SqoopException(DerbyRepoError.DERBYREPO_0038, e);
731
    } finally {
741
    } finally {
732
      closeStatements(updateConnectorStatement, deleteForm, deleteInput);
742
      closeStatements(updateConnectorStatement, deleteForm, deleteInput);
733
    }
743
    }
734
    insertFormsForConnector(mConnector, conn);
744
    insertFormsForConnector(mConnector, conn);
[+20] [20] 13 lines
[+20] [+] public void updateFramework(MFramework mFramework, Connection conn) {
748

    
   
758

   
749
      deleteInput.executeUpdate();
759
      deleteInput.executeUpdate();
750
      deleteForm.executeUpdate();
760
      deleteForm.executeUpdate();
751

    
   
761

   
752
    } catch (SQLException e) {
762
    } catch (SQLException e) {

    
   
763
      logException(e, mFramework);
753
      throw new SqoopException(DerbyRepoError.DERBYREPO_0038, e);
764
      throw new SqoopException(DerbyRepoError.DERBYREPO_0038, e);
754
    } finally {
765
    } finally {
755
      closeStatements(deleteForm, deleteInput);
766
      closeStatements(deleteForm, deleteInput);
756
    }
767
    }
757
    insertFormsForFramework(mFramework, conn);
768
    insertFormsForFramework(mFramework, conn);
[+20] [20] 40 lines
[+20] [+] public void createJob(MJob job, Connection conn) {
798
                        conn);
809
                        conn);
799

    
   
810

   
800
      job.setPersistenceId(jobId);
811
      job.setPersistenceId(jobId);
801

    
   
812

   
802
    } catch (SQLException ex) {
813
    } catch (SQLException ex) {

    
   
814
      logException(ex, job);
803
      throw new SqoopException(DerbyRepoError.DERBYREPO_0026, ex);
815
      throw new SqoopException(DerbyRepoError.DERBYREPO_0026, ex);
804
    } finally {
816
    } finally {
805
      closeStatements(stmt);
817
      closeStatements(stmt);
806
    }
818
    }
807
  }
819
  }
[+20] [20] 28 lines
[+20] [+] public void updateJob(MJob job, Connection conn) {
836
                        job.getPersistenceId(),
848
                        job.getPersistenceId(),
837
                        job.getFrameworkPart().getForms(),
849
                        job.getFrameworkPart().getForms(),
838
                        conn);
850
                        conn);
839

    
   
851

   
840
    } catch (SQLException ex) {
852
    } catch (SQLException ex) {

    
   
853
      logException(ex, job);
841
      throw new SqoopException(DerbyRepoError.DERBYREPO_0027, ex);
854
      throw new SqoopException(DerbyRepoError.DERBYREPO_0027, ex);
842
    } finally {
855
    } finally {
843
      closeStatements(deleteStmt, updateStmt);
856
      closeStatements(deleteStmt, updateStmt);
844
    }
857
    }
845
  }
858
  }
[+20] [20] 13 lines
[+20] [+] public boolean existsJob(long id, Connection conn) {
859
      // Should be always valid in query with count
872
      // Should be always valid in query with count
860
      rs.next();
873
      rs.next();
861

    
   
874

   
862
      return rs.getLong(1) == 1;
875
      return rs.getLong(1) == 1;
863
    } catch (SQLException ex) {
876
    } catch (SQLException ex) {

    
   
877
      logException(ex, id);
864
      throw new SqoopException(DerbyRepoError.DERBYREPO_0029, ex);
878
      throw new SqoopException(DerbyRepoError.DERBYREPO_0029, ex);
865
    } finally {
879
    } finally {
866
      closeResultSets(rs);
880
      closeResultSets(rs);
867
      closeStatements(stmt);
881
      closeStatements(stmt);
868
    }
882
    }
[+20] [20] 26 lines
[+20] [+] public void deleteJob(long id, Connection conn) {
895
      deleteJobInputs(id, conn);
909
      deleteJobInputs(id, conn);
896
      dlt = conn.prepareStatement(STMT_DELETE_JOB);
910
      dlt = conn.prepareStatement(STMT_DELETE_JOB);
897
      dlt.setLong(1, id);
911
      dlt.setLong(1, id);
898
      dlt.executeUpdate();
912
      dlt.executeUpdate();
899
    } catch (SQLException ex) {
913
    } catch (SQLException ex) {

    
   
914
      logException(ex, id);
900
      throw new SqoopException(DerbyRepoError.DERBYREPO_0028, ex);
915
      throw new SqoopException(DerbyRepoError.DERBYREPO_0028, ex);
901
    } finally {
916
    } finally {
902
      closeStatements(dlt);
917
      closeStatements(dlt);
903
    }
918
    }
904
  }
919
  }
[+20] [20] 7 lines
[+20] [+] public void deleteJobInputs(long id, Connection conn) {
912
    try {
927
    try {
913
      dltInput = conn.prepareStatement(STMT_DELETE_JOB_INPUT);
928
      dltInput = conn.prepareStatement(STMT_DELETE_JOB_INPUT);
914
      dltInput.setLong(1, id);
929
      dltInput.setLong(1, id);
915
      dltInput.executeUpdate();
930
      dltInput.executeUpdate();
916
    } catch (SQLException ex) {
931
    } catch (SQLException ex) {

    
   
932
      logException(ex, id);
917
      throw new SqoopException(DerbyRepoError.DERBYREPO_0028, ex);
933
      throw new SqoopException(DerbyRepoError.DERBYREPO_0028, ex);
918
    } finally {
934
    } finally {
919
      closeStatements(dltInput);
935
      closeStatements(dltInput);
920
    }
936
    }
921
  }
937
  }
[+20] [20] 17 lines
[+20] [+] public MJob findJob(long id, Connection conn) {
939

    
   
955

   
940
      // Return the first and only one connection object
956
      // Return the first and only one connection object
941
      return jobs.get(0);
957
      return jobs.get(0);
942

    
   
958

   
943
    } catch (SQLException ex) {
959
    } catch (SQLException ex) {

    
   
960
      logException(ex, id);
944
      throw new SqoopException(DerbyRepoError.DERBYREPO_0031, ex);
961
      throw new SqoopException(DerbyRepoError.DERBYREPO_0031, ex);
945
    } finally {
962
    } finally {
946
      closeStatements(stmt);
963
      closeStatements(stmt);
947
    }
964
    }
948
  }
965
  }
[+20] [20] 8 lines
[+20] public MJob findJob(long id, Connection conn) {
957
      stmt = conn.prepareStatement(STMT_SELECT_JOB_ALL);
974
      stmt = conn.prepareStatement(STMT_SELECT_JOB_ALL);
958

    
   
975

   
959
      return loadJobs(stmt, conn);
976
      return loadJobs(stmt, conn);
960

    
   
977

   
961
    } catch (SQLException ex) {
978
    } catch (SQLException ex) {

    
   
979
      logException(ex);
962
      throw new SqoopException(DerbyRepoError.DERBYREPO_0031, ex);
980
      throw new SqoopException(DerbyRepoError.DERBYREPO_0031, ex);
963
    } finally {
981
    } finally {
964
      closeStatements(stmt);
982
      closeStatements(stmt);
965
    }
983
    }
966
  }
984
  }
[+20] [20] 8 lines
[+20] public MJob findJob(long id, Connection conn) {
975
      stmt = conn.prepareStatement(STMT_SELECT_ALL_JOBS_FOR_CONNECTOR);
993
      stmt = conn.prepareStatement(STMT_SELECT_ALL_JOBS_FOR_CONNECTOR);
976
      stmt.setLong(1, connectorId);
994
      stmt.setLong(1, connectorId);
977
      return loadJobs(stmt, conn);
995
      return loadJobs(stmt, conn);
978

    
   
996

   
979
    } catch (SQLException ex) {
997
    } catch (SQLException ex) {

    
   
998
      logException(ex, connectorId);
980
      throw new SqoopException(DerbyRepoError.DERBYREPO_0031, ex);
999
      throw new SqoopException(DerbyRepoError.DERBYREPO_0031, ex);
981
    } finally {
1000
    } finally {
982
      closeStatements(stmt);
1001
      closeStatements(stmt);
983
    }
1002
    }
984
  }
1003
  }
[+20] [20] 37 lines
[+20] [+] public void createSubmission(MSubmission submission, Connection conn) {
1022

    
   
1041

   
1023
      // Save created persistence id
1042
      // Save created persistence id
1024
      submission.setPersistenceId(submissionId);
1043
      submission.setPersistenceId(submissionId);
1025

    
   
1044

   
1026
    } catch (SQLException ex) {
1045
    } catch (SQLException ex) {

    
   
1046
      logException(ex, submission);
1027
      throw new SqoopException(DerbyRepoError.DERBYREPO_0034, ex);
1047
      throw new SqoopException(DerbyRepoError.DERBYREPO_0034, ex);
1028
    } finally {
1048
    } finally {
1029
      closeStatements(stmt);
1049
      closeStatements(stmt);
1030
    }
1050
    }
1031
  }
1051
  }
[+20] [20] 13 lines
[+20] [+] public boolean existsSubmission(long submissionId, Connection conn) {
1045
      // Should be always valid in query with count
1065
      // Should be always valid in query with count
1046
      rs.next();
1066
      rs.next();
1047

    
   
1067

   
1048
      return rs.getLong(1) == 1;
1068
      return rs.getLong(1) == 1;
1049
    } catch (SQLException ex) {
1069
    } catch (SQLException ex) {

    
   
1070
      logException(ex, submissionId);
1050
      throw new SqoopException(DerbyRepoError.DERBYREPO_0033, ex);
1071
      throw new SqoopException(DerbyRepoError.DERBYREPO_0033, ex);
1051
    } finally {
1072
    } finally {
1052
      closeResultSets(rs);
1073
      closeResultSets(rs);
1053
      closeStatements(stmt);
1074
      closeStatements(stmt);
1054
    }
1075
    }
[+20] [20] 26 lines
[+20] [+] public void updateSubmission(MSubmission submission, Connection conn) {
1081
      if(submission.getCounters() != null) {
1102
      if(submission.getCounters() != null) {
1082
        createSubmissionCounters(submission.getPersistenceId(), submission.getCounters(), conn);
1103
        createSubmissionCounters(submission.getPersistenceId(), submission.getCounters(), conn);
1083
      }
1104
      }
1084

    
   
1105

   
1085
    } catch (SQLException ex) {
1106
    } catch (SQLException ex) {

    
   
1107
      logException(ex, submission);
1086
      throw new SqoopException(DerbyRepoError.DERBYREPO_0035, ex);
1108
      throw new SqoopException(DerbyRepoError.DERBYREPO_0035, ex);
1087
    } finally {
1109
    } finally {
1088
      closeStatements(stmt, deleteStmt);
1110
      closeStatements(stmt, deleteStmt);
1089
    }
1111
    }
1090
  }
1112
  }
[+20] [20] 8 lines
[+20] [+] public void purgeSubmissions(Date threshold, Connection conn) {
1099
      stmt = conn.prepareStatement(STMT_PURGE_SUBMISSIONS);
1121
      stmt = conn.prepareStatement(STMT_PURGE_SUBMISSIONS);
1100
      stmt.setTimestamp(1, new Timestamp(threshold.getTime()));
1122
      stmt.setTimestamp(1, new Timestamp(threshold.getTime()));
1101
      stmt.executeUpdate();
1123
      stmt.executeUpdate();
1102

    
   
1124

   
1103
    } catch (SQLException ex) {
1125
    } catch (SQLException ex) {

    
   
1126
      logException(ex, threshold);
1104
      throw new SqoopException(DerbyRepoError.DERBYREPO_0036, ex);
1127
      throw new SqoopException(DerbyRepoError.DERBYREPO_0036, ex);
1105
    } finally {
1128
    } finally {
1106
      closeStatements(stmt);
1129
      closeStatements(stmt);
1107
    }
1130
    }
1108
  }
1131
  }
[+20] [20] 19 lines
[+20] public void purgeSubmissions(Date threshold, Connection conn) {
1128

    
   
1151

   
1129
        rs.close();
1152
        rs.close();
1130
        rs = null;
1153
        rs = null;
1131
      }
1154
      }
1132
    } catch (SQLException ex) {
1155
    } catch (SQLException ex) {

    
   
1156
      logException(ex);
1133
      throw new SqoopException(DerbyRepoError.DERBYREPO_0037, ex);
1157
      throw new SqoopException(DerbyRepoError.DERBYREPO_0037, ex);
1134
    } finally {
1158
    } finally {
1135
      closeResultSets(rs);
1159
      closeResultSets(rs);
1136
      closeStatements(stmt);
1160
      closeStatements(stmt);
1137
    }
1161
    }
[+20] [20] 18 lines
[+20] [+] public MSubmission findSubmissionLastForJob(long jobId, Connection conn) {
1156
        return null;
1180
        return null;
1157
      }
1181
      }
1158

    
   
1182

   
1159
      return loadSubmission(rs, conn);
1183
      return loadSubmission(rs, conn);
1160
    } catch (SQLException ex) {
1184
    } catch (SQLException ex) {

    
   
1185
      logException(ex, jobId);
1161
      throw new SqoopException(DerbyRepoError.DERBYREPO_0037, ex);
1186
      throw new SqoopException(DerbyRepoError.DERBYREPO_0037, ex);
1162
    } finally {
1187
    } finally {
1163
      closeResultSets(rs);
1188
      closeResultSets(rs);
1164
      closeStatements(stmt);
1189
      closeStatements(stmt);
1165
    }
1190
    }
[+20] [20] 658 lines
[+20] [+] private void closeResultSets(ResultSet ... resultSets) {
1824
   * Close all given statements.
1849
   * Close all given statements.
1825
   *
1850
   *
1826
   * Any occurring exception is silently ignored and logged.
1851
   * Any occurring exception is silently ignored and logged.
1827
   *
1852
   *
1828
   * @param stmts Statements to close
1853
   * @param stmts Statements to close
1829
   */  private void closeStatements(Statement... stmts) {
1854
   */

    
   
1855
  private void closeStatements(Statement... stmts) {
1830
    for (Statement stmt : stmts) {
1856
    for (Statement stmt : stmts) {
1831
      if(stmt != null) {
1857
      if(stmt != null) {
1832
        try {
1858
        try {
1833
          stmt.close();
1859
          stmt.close();
1834
        } catch (SQLException ex) {
1860
        } catch (SQLException ex) {
1835
          LOG.error("Exception during closing statement", ex);
1861
          LOG.error("Exception during closing statement", ex);
1836
        }
1862
        }
1837
      }
1863
      }
1838
    }
1864
    }
1839
  }
1865
  }

    
   
1866

   

    
   
1867
  /**

    
   
1868
   * Log exception and all String variant of arbitrary number of objects.

    
   
1869
   *

    
   
1870
   * This method is useful to log SQLException with all objects that were

    
   
1871
   * used in the query generation to see where is the issue.

    
   
1872
   *

    
   
1873
   * @param throwable Arbitrary throwable object

    
   
1874
   * @param objects Arbitrary array of associated objects

    
   
1875
   */

    
   
1876
  private void logException(Throwable throwable, Object ...objects) {

    
   
1877
    LOG.error("Exception in repository operation", throwable);

    
   
1878
    LOG.error("Associated objects: "+ objects.length);

    
   
1879
    for(Object object : objects) {

    
   
1880
      LOG.error("\t" + object.getClass().getSimpleName() + ": " + object.toString());

    
   
1881
    }

    
   
1882
  }
1840
}
1883
}
  1. repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java: Loading...