Review Board 1.7.22


Sqoop2: Rename queries in Derby repository to have the same naming scheme

Review Request #12722 - Created July 18, 2013 and updated

Vasanth kumar RJ
SQOOP-1135
Reviewers
Sqoop
sqoop-sqoop2
Adding SQ prefix to the variables.
Done
repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
Revision f717abf New Change
[20] 103 lines
[+20] [+] public void registerConnector(MConnector mc, Connection conn) {
104
   */
104
   */
105
  private void insertFormsForFramework(MFramework mf, Connection conn) {
105
  private void insertFormsForFramework(MFramework mf, Connection conn) {
106
    PreparedStatement baseFormStmt = null;
106
    PreparedStatement baseFormStmt = null;
107
    PreparedStatement baseInputStmt = null;
107
    PreparedStatement baseInputStmt = null;
108
    try{
108
    try{
109
      baseFormStmt = conn.prepareStatement(STMT_INSERT_FORM_BASE,
109
      baseFormStmt = conn.prepareStatement(STMT_INSERT_SQ_FORM_BASE,
110
        Statement.RETURN_GENERATED_KEYS);
110
        Statement.RETURN_GENERATED_KEYS);
111

    
   
111

   
112
      baseInputStmt = conn.prepareStatement(STMT_INSERT_INPUT_BASE,
112
      baseInputStmt = conn.prepareStatement(STMT_INSERT_SQ_INPUT_BASE,
113
        Statement.RETURN_GENERATED_KEYS);
113
        Statement.RETURN_GENERATED_KEYS);
114

    
   
114

   
115
      // Register connector forms
115
      // Register connector forms
116
      registerForms(null, null, mf.getConnectionForms().getForms(),
116
      registerForms(null, null, mf.getConnectionForms().getForms(),
117
        MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
117
        MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
[+20] [20] 21 lines
[+20] private void insertFormsForFramework(MFramework mf, Connection conn) {
139
  private void insertFormsForConnector (MConnector mc, Connection conn) {
139
  private void insertFormsForConnector (MConnector mc, Connection conn) {
140
    long connectorId = mc.getPersistenceId();
140
    long connectorId = mc.getPersistenceId();
141
    PreparedStatement baseFormStmt = null;
141
    PreparedStatement baseFormStmt = null;
142
    PreparedStatement baseInputStmt = null;
142
    PreparedStatement baseInputStmt = null;
143
    try{
143
    try{
144
      baseFormStmt = conn.prepareStatement(STMT_INSERT_FORM_BASE,
144
      baseFormStmt = conn.prepareStatement(STMT_INSERT_SQ_FORM_BASE,
145
        Statement.RETURN_GENERATED_KEYS);
145
        Statement.RETURN_GENERATED_KEYS);
146

    
   
146

   
147
      baseInputStmt = conn.prepareStatement(STMT_INSERT_INPUT_BASE,
147
      baseInputStmt = conn.prepareStatement(STMT_INSERT_SQ_INPUT_BASE,
148
        Statement.RETURN_GENERATED_KEYS);
148
        Statement.RETURN_GENERATED_KEYS);
149

    
   
149

   
150
      // Register connector forms
150
      // Register connector forms
151
      registerForms(connectorId, null, mc.getConnectionForms().getForms(),
151
      registerForms(connectorId, null, mc.getConnectionForms().getForms(),
152
        MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
152
        MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
[+20] [20] 14 lines
[+20] private void insertFormsForConnector (MConnector mc, Connection conn) {
167
  }
167
  }
168

    
   
168

   
169
  private long getConnectorId(MConnector mc, Connection conn) {
169
  private long getConnectorId(MConnector mc, Connection conn) {
170
    PreparedStatement baseConnectorStmt = null;
170
    PreparedStatement baseConnectorStmt = null;
171
    try {
171
    try {
172
      baseConnectorStmt = conn.prepareStatement(STMT_INSERT_CONNECTOR_BASE,
172
      baseConnectorStmt = conn.prepareStatement(STMT_INSERT_SQ_CONNECTOR_BASE,
173
        Statement.RETURN_GENERATED_KEYS);
173
        Statement.RETURN_GENERATED_KEYS);
174
      baseConnectorStmt.setString(1, mc.getUniqueName());
174
      baseConnectorStmt.setString(1, mc.getUniqueName());
175
      baseConnectorStmt.setString(2, mc.getClassName());
175
      baseConnectorStmt.setString(2, mc.getClassName());
176
      baseConnectorStmt.setString(3, mc.getVersion());
176
      baseConnectorStmt.setString(3, mc.getVersion());
177

    
   
177

   
[+20] [20] 110 lines
[+20] [+] public int detectVersion(Connection conn) {
288
      closeResultSets(rs);
288
      closeResultSets(rs);
289
    }
289
    }
290

    
   
290

   
291
    // Normal version detection, select and return the version
291
    // Normal version detection, select and return the version
292
    try {
292
    try {
293
      stmt = conn.prepareStatement(STMT_SELECT_SYSTEM);
293
      stmt = conn.prepareStatement(STMT_SELECT_SQ_SYSTEM);
294
      stmt.setString(1, DerbyRepoConstants.SYSKEY_VERSION);
294
      stmt.setString(1, DerbyRepoConstants.SYSKEY_VERSION);
295
      rs = stmt.executeQuery();
295
      rs = stmt.executeQuery();
296

    
   
296

   
297
      if(!rs.next()) {
297
      if(!rs.next()) {
298
        return 0;
298
        return 0;
[+20] [20] 36 lines
[+20] [+] public void createOrUpdateInternals(Connection conn) {
335
    }
335
    }
336

    
   
336

   
337
    ResultSet rs = null;
337
    ResultSet rs = null;
338
    PreparedStatement stmt = null;
338
    PreparedStatement stmt = null;
339
    try {
339
    try {
340
      stmt = conn.prepareStatement(STMT_DELETE_SYSTEM);
340
      stmt = conn.prepareStatement(STMT_DELETE_SQ_SYSTEM);
341
      stmt.setString(1, DerbyRepoConstants.SYSKEY_VERSION);
341
      stmt.setString(1, DerbyRepoConstants.SYSKEY_VERSION);
342
      stmt.executeUpdate();
342
      stmt.executeUpdate();
343

    
   
343

   
344
      closeStatements(stmt);
344
      closeStatements(stmt);
345

    
   
345

   
346
      stmt = conn.prepareStatement(STMT_INSERT_SYSTEM);
346
      stmt = conn.prepareStatement(STMT_INSERT_SQ_SYSTEM);
347
      stmt.setString(1, DerbyRepoConstants.SYSKEY_VERSION);
347
      stmt.setString(1, DerbyRepoConstants.SYSKEY_VERSION);
348
      stmt.setString(2, "" + DerbyRepoConstants.VERSION);
348
      stmt.setString(2, "" + DerbyRepoConstants.VERSION);
349
      stmt.executeUpdate();
349
      stmt.executeUpdate();
350
    } catch (SQLException e) {
350
    } catch (SQLException e) {
351
      LOG.error("Can't persist the repository version", e);
351
      LOG.error("Can't persist the repository version", e);
[+20] [20] 29 lines
[+20] [+] public MConnector findConnector(String shortName, Connection conn) {
381
    MConnector mc = null;
381
    MConnector mc = null;
382
    PreparedStatement baseConnectorFetchStmt = null;
382
    PreparedStatement baseConnectorFetchStmt = null;
383
    PreparedStatement formFetchStmt = null;
383
    PreparedStatement formFetchStmt = null;
384
    PreparedStatement inputFetchStmt = null;
384
    PreparedStatement inputFetchStmt = null;
385
    try {
385
    try {
386
      baseConnectorFetchStmt = conn.prepareStatement(STMT_FETCH_BASE_CONNECTOR);
386
      baseConnectorFetchStmt = conn.prepareStatement(STMT_FETCH_BASE_SQ_CONNECTOR);
387
      baseConnectorFetchStmt.setString(1, shortName);
387
      baseConnectorFetchStmt.setString(1, shortName);
388
      ResultSet rsetBaseConnector = baseConnectorFetchStmt.executeQuery();
388
      ResultSet rsetBaseConnector = baseConnectorFetchStmt.executeQuery();
389

    
   
389

   
390
      if (!rsetBaseConnector.next()) {
390
      if (!rsetBaseConnector.next()) {
391
        LOG.debug("No connector found by name: " + shortName);
391
        LOG.debug("No connector found by name: " + shortName);
392
        return null;
392
        return null;
393
      }
393
      }
394

    
   
394

   
395
      long connectorId = rsetBaseConnector.getLong(1);
395
      long connectorId = rsetBaseConnector.getLong(1);
396
      String connectorName = rsetBaseConnector.getString(2);
396
      String connectorName = rsetBaseConnector.getString(2);
397
      String connectorClassName = rsetBaseConnector.getString(3);
397
      String connectorClassName = rsetBaseConnector.getString(3);
398
      String connectorVersion = rsetBaseConnector.getString(4);
398
      String connectorVersion = rsetBaseConnector.getString(4);
399

    
   
399

   
400
      formFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_CONNECTOR);
400
      formFetchStmt = conn.prepareStatement(STMT_FETCH_SQ_FORM_CONNECTOR);
401
      formFetchStmt.setLong(1, connectorId);
401
      formFetchStmt.setLong(1, connectorId);
402
      inputFetchStmt = conn.prepareStatement(STMT_FETCH_INPUT);
402
      inputFetchStmt = conn.prepareStatement(STMT_FETCH_SQ_INPUT);
403

    
   
403

   
404
      List<MForm> connectionForms = new ArrayList<MForm>();
404
      List<MForm> connectionForms = new ArrayList<MForm>();
405
      Map<MJob.Type, List<MForm>> jobForms =
405
      Map<MJob.Type, List<MForm>> jobForms =
406
        new HashMap<MJob.Type, List<MForm>>();
406
        new HashMap<MJob.Type, List<MForm>>();
407

    
   
407

   
[+20] [20] 30 lines
[+20] [+] public void registerFramework(MFramework mf, Connection conn) {
438
    }
438
    }
439

    
   
439

   
440
    PreparedStatement baseFormStmt = null;
440
    PreparedStatement baseFormStmt = null;
441
    PreparedStatement baseInputStmt = null;
441
    PreparedStatement baseInputStmt = null;
442
    try {
442
    try {
443
      baseFormStmt = conn.prepareStatement(STMT_INSERT_FORM_BASE,
443
      baseFormStmt = conn.prepareStatement(STMT_INSERT_SQ_FORM_BASE,
444
          Statement.RETURN_GENERATED_KEYS);
444
          Statement.RETURN_GENERATED_KEYS);
445
      baseInputStmt = conn.prepareStatement(STMT_INSERT_INPUT_BASE,
445
      baseInputStmt = conn.prepareStatement(STMT_INSERT_SQ_INPUT_BASE,
446
          Statement.RETURN_GENERATED_KEYS);
446
          Statement.RETURN_GENERATED_KEYS);
447

    
   
447

   
448
      // Register connector forms
448
      // Register connector forms
449
      registerForms(null, null, mf.getConnectionForms().getForms(),
449
      registerForms(null, null, mf.getConnectionForms().getForms(),
450
        MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
450
        MFormType.CONNECTION.name(), baseFormStmt, baseInputStmt);
[+20] [20] 23 lines
[+20] public void registerFramework(MFramework mf, Connection conn) {
474
    LOG.debug("Looking up framework metadata");
474
    LOG.debug("Looking up framework metadata");
475
    MFramework mf = null;
475
    MFramework mf = null;
476
    PreparedStatement formFetchStmt = null;
476
    PreparedStatement formFetchStmt = null;
477
    PreparedStatement inputFetchStmt = null;
477
    PreparedStatement inputFetchStmt = null;
478
    try {
478
    try {
479
      formFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_FRAMEWORK);
479
      formFetchStmt = conn.prepareStatement(STMT_FETCH_SQ_FORM_FRAMEWORK);
480
      inputFetchStmt = conn.prepareStatement(STMT_FETCH_INPUT);
480
      inputFetchStmt = conn.prepareStatement(STMT_FETCH_SQ_INPUT);
481

    
   
481

   
482
      List<MForm> connectionForms = new ArrayList<MForm>();
482
      List<MForm> connectionForms = new ArrayList<MForm>();
483
      Map<MJob.Type, List<MForm>> jobForms =
483
      Map<MJob.Type, List<MForm>> jobForms =
484
        new HashMap<MJob.Type, List<MForm>>();
484
        new HashMap<MJob.Type, List<MForm>>();
485

    
   
485

   
[+20] [20] 51 lines
[+20] [+] public String validationQuery() {
537
  @Override
537
  @Override
538
  public void createConnection(MConnection connection, Connection conn) {
538
  public void createConnection(MConnection connection, Connection conn) {
539
    PreparedStatement stmt = null;
539
    PreparedStatement stmt = null;
540
    int result;
540
    int result;
541
    try {
541
    try {
542
      stmt = conn.prepareStatement(STMT_INSERT_CONNECTION,
542
      stmt = conn.prepareStatement(STMT_INSERT_SQ_CONNECTION,
543
        Statement.RETURN_GENERATED_KEYS);
543
        Statement.RETURN_GENERATED_KEYS);
544
      stmt.setString(1, connection.getName());
544
      stmt.setString(1, connection.getName());
545
      stmt.setLong(2, connection.getConnectorId());
545
      stmt.setLong(2, connection.getConnectorId());
546
      stmt.setTimestamp(3, new Timestamp(connection.getCreationDate().getTime()));
546
      stmt.setTimestamp(3, new Timestamp(connection.getCreationDate().getTime()));
547
      stmt.setTimestamp(4, new Timestamp(connection.getLastUpdateDate().getTime()));
547
      stmt.setTimestamp(4, new Timestamp(connection.getLastUpdateDate().getTime()));
[+20] [20] 10 lines
[+20] public void createConnection(MConnection connection, Connection conn) {
558
        throw new SqoopException(DerbyRepoError.DERBYREPO_0013);
558
        throw new SqoopException(DerbyRepoError.DERBYREPO_0013);
559
      }
559
      }
560

    
   
560

   
561
      long connectionId = rsetConnectionId.getLong(1);
561
      long connectionId = rsetConnectionId.getLong(1);
562

    
   
562

   
563
      createInputValues(STMT_INSERT_CONNECTION_INPUT,
563
      createInputValues(STMT_INSERT_SQ_CONNECTION_INPUT,
564
        connectionId,
564
        connectionId,
565
        connection.getConnectorPart().getForms(),
565
        connection.getConnectorPart().getForms(),
566
        conn);
566
        conn);
567
      createInputValues(STMT_INSERT_CONNECTION_INPUT,
567
      createInputValues(STMT_INSERT_SQ_CONNECTION_INPUT,
568
        connectionId,
568
        connectionId,
569
        connection.getFrameworkPart().getForms(),
569
        connection.getFrameworkPart().getForms(),
570
        conn);
570
        conn);
571

    
   
571

   
572
      connection.setPersistenceId(connectionId);
572
      connection.setPersistenceId(connectionId);
[+20] [20] 13 lines
[+20] public void createConnection(MConnection connection, Connection conn) {
586
  public void updateConnection(MConnection connection, Connection conn) {
586
  public void updateConnection(MConnection connection, Connection conn) {
587
    PreparedStatement deleteStmt = null;
587
    PreparedStatement deleteStmt = null;
588
    PreparedStatement updateStmt = null;
588
    PreparedStatement updateStmt = null;
589
    try {
589
    try {
590
      // Firstly remove old values
590
      // Firstly remove old values
591
      deleteStmt = conn.prepareStatement(STMT_DELETE_CONNECTION_INPUT);
591
      deleteStmt = conn.prepareStatement(STMT_DELETE_SQ_CONNECTION_INPUT);
592
      deleteStmt.setLong(1, connection.getPersistenceId());
592
      deleteStmt.setLong(1, connection.getPersistenceId());
593
      deleteStmt.executeUpdate();
593
      deleteStmt.executeUpdate();
594

    
   
594

   
595
      // Update CONNECTION table
595
      // Update CONNECTION table
596
      updateStmt = conn.prepareStatement(STMT_UPDATE_CONNECTION);
596
      updateStmt = conn.prepareStatement(STMT_UPDATE_SQ_CONNECTION);
597
      updateStmt.setString(1, connection.getName());
597
      updateStmt.setString(1, connection.getName());
598
      updateStmt.setTimestamp(2, new Timestamp(new Date().getTime()));
598
      updateStmt.setTimestamp(2, new Timestamp(new Date().getTime()));
599

    
   
599

   
600
      updateStmt.setLong(3, connection.getPersistenceId());
600
      updateStmt.setLong(3, connection.getPersistenceId());
601
      updateStmt.executeUpdate();
601
      updateStmt.executeUpdate();
602

    
   
602

   
603
      // And reinsert new values
603
      // And reinsert new values
604
      createInputValues(STMT_INSERT_CONNECTION_INPUT,
604
      createInputValues(STMT_INSERT_SQ_CONNECTION_INPUT,
605
        connection.getPersistenceId(),
605
        connection.getPersistenceId(),
606
        connection.getConnectorPart().getForms(),
606
        connection.getConnectorPart().getForms(),
607
        conn);
607
        conn);
608
      createInputValues(STMT_INSERT_CONNECTION_INPUT,
608
      createInputValues(STMT_INSERT_SQ_CONNECTION_INPUT,
609
        connection.getPersistenceId(),
609
        connection.getPersistenceId(),
610
        connection.getFrameworkPart().getForms(),
610
        connection.getFrameworkPart().getForms(),
611
        conn);
611
        conn);
612

    
   
612

   
613
    } catch (SQLException ex) {
613
    } catch (SQLException ex) {
[+20] [20] 10 lines
[+20] public void updateConnection(MConnection connection, Connection conn) {
624
  @Override
624
  @Override
625
  public boolean existsConnection(long id, Connection conn) {
625
  public boolean existsConnection(long id, Connection conn) {
626
    PreparedStatement stmt = null;
626
    PreparedStatement stmt = null;
627
    ResultSet rs = null;
627
    ResultSet rs = null;
628
    try {
628
    try {
629
      stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_CHECK);
629
      stmt = conn.prepareStatement(STMT_SELECT_SQ_CONNECTION_CHECK);
630
      stmt.setLong(1, id);
630
      stmt.setLong(1, id);
631
      rs = stmt.executeQuery();
631
      rs = stmt.executeQuery();
632

    
   
632

   
633
      // Should be always valid in query with count
633
      // Should be always valid in query with count
634
      rs.next();
634
      rs.next();
[+20] [20] 12 lines
[+20] public boolean existsConnection(long id, Connection conn) {
647
  public boolean inUseConnection(long connectionId, Connection conn) {
647
  public boolean inUseConnection(long connectionId, Connection conn) {
648
    PreparedStatement stmt = null;
648
    PreparedStatement stmt = null;
649
    ResultSet rs = null;
649
    ResultSet rs = null;
650

    
   
650

   
651
    try {
651
    try {
652
      stmt = conn.prepareStatement(STMT_SELECT_JOBS_FOR_CONNECTION_CHECK);
652
      stmt = conn.prepareStatement(STMT_SELECT_SQ_JOBS_FOR_CONNECTION_CHECK);
653
      stmt.setLong(1, connectionId);
653
      stmt.setLong(1, connectionId);
654
      rs = stmt.executeQuery();
654
      rs = stmt.executeQuery();
655

    
   
655

   
656
      // Should be always valid in case of count(*) query
656
      // Should be always valid in case of count(*) query
657
      rs.next();
657
      rs.next();
[+20] [20] 16 lines
[+20] public boolean inUseConnection(long connectionId, Connection conn) {
674
  public void deleteConnection(long id, Connection conn) {
674
  public void deleteConnection(long id, Connection conn) {
675
    PreparedStatement dltConn = null;
675
    PreparedStatement dltConn = null;
676

    
   
676

   
677
    try {
677
    try {
678
      deleteConnectionInputs(id, conn);
678
      deleteConnectionInputs(id, conn);
679
      dltConn = conn.prepareStatement(STMT_DELETE_CONNECTION);
679
      dltConn = conn.prepareStatement(STMT_DELETE_SQ_CONNECTION);
680
      dltConn.setLong(1, id);
680
      dltConn.setLong(1, id);
681
      dltConn.executeUpdate();
681
      dltConn.executeUpdate();
682
    } catch (SQLException ex) {
682
    } catch (SQLException ex) {
683
      logException(ex, id);
683
      logException(ex, id);
684
      throw new SqoopException(DerbyRepoError.DERBYREPO_0022, ex);
684
      throw new SqoopException(DerbyRepoError.DERBYREPO_0022, ex);
[+20] [20] 7 lines
[+20] public void deleteConnection(long id, Connection conn) {
692
   */
692
   */
693
  @Override
693
  @Override
694
  public void deleteConnectionInputs(long id, Connection conn) {
694
  public void deleteConnectionInputs(long id, Connection conn) {
695
    PreparedStatement dltConnInput = null;
695
    PreparedStatement dltConnInput = null;
696
    try {
696
    try {
697
      dltConnInput = conn.prepareStatement(STMT_DELETE_CONNECTION_INPUT);
697
      dltConnInput = conn.prepareStatement(STMT_DELETE_SQ_CONNECTION_INPUT);
698
      dltConnInput.setLong(1, id);
698
      dltConnInput.setLong(1, id);
699
      dltConnInput.executeUpdate();
699
      dltConnInput.executeUpdate();
700
    } catch (SQLException ex) {
700
    } catch (SQLException ex) {
701
      logException(ex, id);
701
      logException(ex, id);
702
      throw new SqoopException(DerbyRepoError.DERBYREPO_0022, ex);
702
      throw new SqoopException(DerbyRepoError.DERBYREPO_0022, ex);
[+20] [20] 7 lines
[+20] public void deleteConnectionInputs(long id, Connection conn) {
710
   */
710
   */
711
  @Override
711
  @Override
712
  public MConnection findConnection(long id, Connection conn) {
712
  public MConnection findConnection(long id, Connection conn) {
713
    PreparedStatement stmt = null;
713
    PreparedStatement stmt = null;
714
    try {
714
    try {
715
      stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_SINGLE);
715
      stmt = conn.prepareStatement(STMT_SELECT_SQ_CONNECTION_SINGLE);
716
      stmt.setLong(1, id);
716
      stmt.setLong(1, id);
717

    
   
717

   
718
      List<MConnection> connections = loadConnections(stmt, conn);
718
      List<MConnection> connections = loadConnections(stmt, conn);
719

    
   
719

   
720
      if(connections.size() != 1) {
720
      if(connections.size() != 1) {
[+20] [20] 17 lines
[+20] public MConnection findConnection(long id, Connection conn) {
738
   */
738
   */
739
  @Override
739
  @Override
740
  public List<MConnection> findConnections(Connection conn) {
740
  public List<MConnection> findConnections(Connection conn) {
741
    PreparedStatement stmt = null;
741
    PreparedStatement stmt = null;
742
    try {
742
    try {
743
      stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_ALL);
743
      stmt = conn.prepareStatement(STMT_SELECT_SQ_CONNECTION_ALL);
744

    
   
744

   
745
      return loadConnections(stmt, conn);
745
      return loadConnections(stmt, conn);
746

    
   
746

   
747
    } catch (SQLException ex) {
747
    } catch (SQLException ex) {
748
      logException(ex);
748
      logException(ex);
[+20] [20] 11 lines
[+20] public MConnection findConnection(long id, Connection conn) {
760
   */
760
   */
761
  @Override
761
  @Override
762
  public List<MConnection> findConnectionsForConnector(long connectorID, Connection conn) {
762
  public List<MConnection> findConnectionsForConnector(long connectorID, Connection conn) {
763
    PreparedStatement stmt = null;
763
    PreparedStatement stmt = null;
764
    try {
764
    try {
765
      stmt = conn.prepareStatement(STMT_SELECT_CONNECTION_FOR_CONNECTOR);
765
      stmt = conn.prepareStatement(STMT_SELECT_SQ_CONNECTION_FOR_CONNECTOR);
766
      stmt.setLong(1, connectorID);
766
      stmt.setLong(1, connectorID);
767

    
   
767

   
768
      return loadConnections(stmt, conn);
768
      return loadConnections(stmt, conn);
769

    
   
769

   
770
    } catch (SQLException ex) {
770
    } catch (SQLException ex) {
[+20] [20] 11 lines
[+20] public MConnection findConnection(long id, Connection conn) {
782
  public void updateConnector(MConnector mConnector, Connection conn) {
782
  public void updateConnector(MConnector mConnector, Connection conn) {
783
    PreparedStatement updateConnectorStatement = null;
783
    PreparedStatement updateConnectorStatement = null;
784
    PreparedStatement deleteForm = null;
784
    PreparedStatement deleteForm = null;
785
    PreparedStatement deleteInput = null;
785
    PreparedStatement deleteInput = null;
786
    try {
786
    try {
787
      updateConnectorStatement = conn.prepareStatement(STMT_UPDATE_CONNECTOR);
787
      updateConnectorStatement = conn.prepareStatement(STMT_UPDATE_SQ_CONNECTOR);
788
      deleteInput = conn.prepareStatement(STMT_DELETE_INPUTS_FOR_CONNECTOR);
788
      deleteInput = conn.prepareStatement(STMT_DELETE_SQ_INPUTS_FOR_CONNECTOR);
789
      deleteForm = conn.prepareStatement(STMT_DELETE_FORMS_FOR_CONNECTOR);
789
      deleteForm = conn.prepareStatement(STMT_DELETE_SQ_FORMS_FOR_CONNECTOR);
790
      updateConnectorStatement.setString(1, mConnector.getUniqueName());
790
      updateConnectorStatement.setString(1, mConnector.getUniqueName());
791
      updateConnectorStatement.setString(2, mConnector.getClassName());
791
      updateConnectorStatement.setString(2, mConnector.getClassName());
792
      updateConnectorStatement.setString(3, mConnector.getVersion());
792
      updateConnectorStatement.setString(3, mConnector.getVersion());
793
      updateConnectorStatement.setLong(4, mConnector.getPersistenceId());
793
      updateConnectorStatement.setLong(4, mConnector.getPersistenceId());
794

    
   
794

   
[+20] [20] 21 lines
[+20] public void updateConnector(MConnector mConnector, Connection conn) {
816
  @Override
816
  @Override
817
  public void updateFramework(MFramework mFramework, Connection conn) {
817
  public void updateFramework(MFramework mFramework, Connection conn) {
818
    PreparedStatement deleteForm = null;
818
    PreparedStatement deleteForm = null;
819
    PreparedStatement deleteInput = null;
819
    PreparedStatement deleteInput = null;
820
    try {
820
    try {
821
      deleteInput = conn.prepareStatement(STMT_DELETE_FRAMEWORK_INPUTS);
821
      deleteInput = conn.prepareStatement(STMT_DELETE_FRAMEWORK_SQ_INPUTS);
822
      deleteForm = conn.prepareStatement(STMT_DELETE_FRAMEWORK_FORMS);
822
      deleteForm = conn.prepareStatement(STMT_DELETE_FRAMEWORK_SQ_FORMS);
823

    
   
823

   
824
      deleteInput.executeUpdate();
824
      deleteInput.executeUpdate();
825
      deleteForm.executeUpdate();
825
      deleteForm.executeUpdate();
826

    
   
826

   
827
    } catch (SQLException e) {
827
    } catch (SQLException e) {
[+20] [20] 12 lines
[+20] public void updateFramework(MFramework mFramework, Connection conn) {
840
  @Override
840
  @Override
841
  public void createJob(MJob job, Connection conn) {
841
  public void createJob(MJob job, Connection conn) {
842
    PreparedStatement stmt = null;
842
    PreparedStatement stmt = null;
843
    int result;
843
    int result;
844
    try {
844
    try {
845
      stmt = conn.prepareStatement(STMT_INSERT_JOB,
845
      stmt = conn.prepareStatement(STMT_INSERT_SQ_JOB,
846
        Statement.RETURN_GENERATED_KEYS);
846
        Statement.RETURN_GENERATED_KEYS);
847
      stmt.setString(1, job.getName());
847
      stmt.setString(1, job.getName());
848
      stmt.setLong(2, job.getConnectionId());
848
      stmt.setLong(2, job.getConnectionId());
849
      stmt.setString(3, job.getType().name());
849
      stmt.setString(3, job.getType().name());
850
      stmt.setTimestamp(4, new Timestamp(job.getCreationDate().getTime()));
850
      stmt.setTimestamp(4, new Timestamp(job.getCreationDate().getTime()));
[+20] [20] 11 lines
[+20] public void createJob(MJob job, Connection conn) {
862
        throw new SqoopException(DerbyRepoError.DERBYREPO_0013);
862
        throw new SqoopException(DerbyRepoError.DERBYREPO_0013);
863
      }
863
      }
864

    
   
864

   
865
      long jobId = rsetJobId.getLong(1);
865
      long jobId = rsetJobId.getLong(1);
866

    
   
866

   
867
      createInputValues(STMT_INSERT_JOB_INPUT,
867
      createInputValues(STMT_INSERT_SQ_JOB_INPUT,
868
                        jobId,
868
                        jobId,
869
                        job.getConnectorPart().getForms(),
869
                        job.getConnectorPart().getForms(),
870
                        conn);
870
                        conn);
871
      createInputValues(STMT_INSERT_JOB_INPUT,
871
      createInputValues(STMT_INSERT_SQ_JOB_INPUT,
872
                        jobId,
872
                        jobId,
873
                        job.getFrameworkPart().getForms(),
873
                        job.getFrameworkPart().getForms(),
874
                        conn);
874
                        conn);
875

    
   
875

   
876
      job.setPersistenceId(jobId);
876
      job.setPersistenceId(jobId);
[+20] [20] 13 lines
[+20] public void createJob(MJob job, Connection conn) {
890
  public void updateJob(MJob job, Connection conn) {
890
  public void updateJob(MJob job, Connection conn) {
891
    PreparedStatement deleteStmt = null;
891
    PreparedStatement deleteStmt = null;
892
    PreparedStatement updateStmt = null;
892
    PreparedStatement updateStmt = null;
893
    try {
893
    try {
894
      // Firstly remove old values
894
      // Firstly remove old values
895
      deleteStmt = conn.prepareStatement(STMT_DELETE_JOB_INPUT);
895
      deleteStmt = conn.prepareStatement(STMT_DELETE_SQ_JOB_INPUT);
896
      deleteStmt.setLong(1, job.getPersistenceId());
896
      deleteStmt.setLong(1, job.getPersistenceId());
897
      deleteStmt.executeUpdate();
897
      deleteStmt.executeUpdate();
898

    
   
898

   
899
      // Update job table
899
      // Update job table
900
      updateStmt = conn.prepareStatement(STMT_UPDATE_JOB);
900
      updateStmt = conn.prepareStatement(STMT_UPDATE_SQ_JOB);
901
      updateStmt.setString(1, job.getName());
901
      updateStmt.setString(1, job.getName());
902
      updateStmt.setTimestamp(2, new Timestamp(new Date().getTime()));
902
      updateStmt.setTimestamp(2, new Timestamp(new Date().getTime()));
903

    
   
903

   
904
      updateStmt.setLong(3, job.getPersistenceId());
904
      updateStmt.setLong(3, job.getPersistenceId());
905
      updateStmt.executeUpdate();
905
      updateStmt.executeUpdate();
906

    
   
906

   
907
      // And reinsert new values
907
      // And reinsert new values
908
      createInputValues(STMT_INSERT_JOB_INPUT,
908
      createInputValues(STMT_INSERT_SQ_JOB_INPUT,
909
                        job.getPersistenceId(),
909
                        job.getPersistenceId(),
910
                        job.getConnectorPart().getForms(),
910
                        job.getConnectorPart().getForms(),
911
                        conn);
911
                        conn);
912
      createInputValues(STMT_INSERT_JOB_INPUT,
912
      createInputValues(STMT_INSERT_SQ_JOB_INPUT,
913
                        job.getPersistenceId(),
913
                        job.getPersistenceId(),
914
                        job.getFrameworkPart().getForms(),
914
                        job.getFrameworkPart().getForms(),
915
                        conn);
915
                        conn);
916

    
   
916

   
917
    } catch (SQLException ex) {
917
    } catch (SQLException ex) {
[+20] [20] 10 lines
[+20] public void updateJob(MJob job, Connection conn) {
928
  @Override
928
  @Override
929
  public boolean existsJob(long id, Connection conn) {
929
  public boolean existsJob(long id, Connection conn) {
930
    PreparedStatement stmt = null;
930
    PreparedStatement stmt = null;
931
    ResultSet rs = null;
931
    ResultSet rs = null;
932
    try {
932
    try {
933
      stmt = conn.prepareStatement(STMT_SELECT_JOB_CHECK);
933
      stmt = conn.prepareStatement(STMT_SELECT_SQ_JOB_CHECK);
934
      stmt.setLong(1, id);
934
      stmt.setLong(1, id);
935
      rs = stmt.executeQuery();
935
      rs = stmt.executeQuery();
936

    
   
936

   
937
      // Should be always valid in query with count
937
      // Should be always valid in query with count
938
      rs.next();
938
      rs.next();
[+20] [20] 31 lines
[+20] [+] public boolean inUseJob(long jobId, Connection conn) {
970
  @Override
970
  @Override
971
  public void deleteJob(long id, Connection conn) {
971
  public void deleteJob(long id, Connection conn) {
972
    PreparedStatement dlt = null;
972
    PreparedStatement dlt = null;
973
    try {
973
    try {
974
      deleteJobInputs(id, conn);
974
      deleteJobInputs(id, conn);
975
      dlt = conn.prepareStatement(STMT_DELETE_JOB);
975
      dlt = conn.prepareStatement(STMT_DELETE_SQ_JOB);
976
      dlt.setLong(1, id);
976
      dlt.setLong(1, id);
977
      dlt.executeUpdate();
977
      dlt.executeUpdate();
978
    } catch (SQLException ex) {
978
    } catch (SQLException ex) {
979
      logException(ex, id);
979
      logException(ex, id);
980
      throw new SqoopException(DerbyRepoError.DERBYREPO_0028, ex);
980
      throw new SqoopException(DerbyRepoError.DERBYREPO_0028, ex);
[+20] [20] 7 lines
[+20] public void deleteJob(long id, Connection conn) {
988
   */
988
   */
989
  @Override
989
  @Override
990
  public void deleteJobInputs(long id, Connection conn) {
990
  public void deleteJobInputs(long id, Connection conn) {
991
    PreparedStatement dltInput = null;
991
    PreparedStatement dltInput = null;
992
    try {
992
    try {
993
      dltInput = conn.prepareStatement(STMT_DELETE_JOB_INPUT);
993
      dltInput = conn.prepareStatement(STMT_DELETE_SQ_JOB_INPUT);
994
      dltInput.setLong(1, id);
994
      dltInput.setLong(1, id);
995
      dltInput.executeUpdate();
995
      dltInput.executeUpdate();
996
    } catch (SQLException ex) {
996
    } catch (SQLException ex) {
997
      logException(ex, id);
997
      logException(ex, id);
998
      throw new SqoopException(DerbyRepoError.DERBYREPO_0028, ex);
998
      throw new SqoopException(DerbyRepoError.DERBYREPO_0028, ex);
[+20] [20] 7 lines
[+20] public void deleteJobInputs(long id, Connection conn) {
1006
   */
1006
   */
1007
  @Override
1007
  @Override
1008
  public MJob findJob(long id, Connection conn) {
1008
  public MJob findJob(long id, Connection conn) {
1009
    PreparedStatement stmt = null;
1009
    PreparedStatement stmt = null;
1010
    try {
1010
    try {
1011
      stmt = conn.prepareStatement(STMT_SELECT_JOB_SINGLE);
1011
      stmt = conn.prepareStatement(STMT_SELECT_SQ_JOB_SINGLE);
1012
      stmt.setLong(1, id);
1012
      stmt.setLong(1, id);
1013

    
   
1013

   
1014
      List<MJob> jobs = loadJobs(stmt, conn);
1014
      List<MJob> jobs = loadJobs(stmt, conn);
1015

    
   
1015

   
1016
      if(jobs.size() != 1) {
1016
      if(jobs.size() != 1) {
[+20] [20] 17 lines
[+20] public MJob findJob(long id, Connection conn) {
1034
   */
1034
   */
1035
  @Override
1035
  @Override
1036
  public List<MJob> findJobs(Connection conn) {
1036
  public List<MJob> findJobs(Connection conn) {
1037
    PreparedStatement stmt = null;
1037
    PreparedStatement stmt = null;
1038
    try {
1038
    try {
1039
      stmt = conn.prepareStatement(STMT_SELECT_JOB_ALL);
1039
      stmt = conn.prepareStatement(STMT_SELECT_SQ_JOB_ALL);
1040

    
   
1040

   
1041
      return loadJobs(stmt, conn);
1041
      return loadJobs(stmt, conn);
1042

    
   
1042

   
1043
    } catch (SQLException ex) {
1043
    } catch (SQLException ex) {
1044
      logException(ex);
1044
      logException(ex);
[+20] [20] 8 lines
[+20] public MJob findJob(long id, Connection conn) {
1053
   */
1053
   */
1054
  @Override
1054
  @Override
1055
  public List<MJob> findJobsForConnector(long connectorId, Connection conn) {
1055
  public List<MJob> findJobsForConnector(long connectorId, Connection conn) {
1056
    PreparedStatement stmt = null;
1056
    PreparedStatement stmt = null;
1057
    try {
1057
    try {
1058
      stmt = conn.prepareStatement(STMT_SELECT_ALL_JOBS_FOR_CONNECTOR);
1058
      stmt = conn.prepareStatement(STMT_SELECT_ALL_SQ_JOBS_FOR_CONNECTOR);
1059
      stmt.setLong(1, connectorId);
1059
      stmt.setLong(1, connectorId);
1060
      return loadJobs(stmt, conn);
1060
      return loadJobs(stmt, conn);
1061

    
   
1061

   
1062
    } catch (SQLException ex) {
1062
    } catch (SQLException ex) {
1063
      logException(ex, connectorId);
1063
      logException(ex, connectorId);
[+20] [20] 9 lines
[+20] public MJob findJob(long id, Connection conn) {
1073
  @Override
1073
  @Override
1074
  public void createSubmission(MSubmission submission, Connection conn) {
1074
  public void createSubmission(MSubmission submission, Connection conn) {
1075
    PreparedStatement stmt = null;
1075
    PreparedStatement stmt = null;
1076
    int result;
1076
    int result;
1077
    try {
1077
    try {
1078
      stmt = conn.prepareStatement(STMT_INSERT_SUBMISSION,
1078
      stmt = conn.prepareStatement(STMT_INSERT_SQ_SUBMISSION,
1079
        Statement.RETURN_GENERATED_KEYS);
1079
        Statement.RETURN_GENERATED_KEYS);
1080
      stmt.setLong(1, submission.getJobId());
1080
      stmt.setLong(1, submission.getJobId());
1081
      stmt.setString(2, submission.getStatus().name());
1081
      stmt.setString(2, submission.getStatus().name());
1082
      stmt.setTimestamp(3, new Timestamp(submission.getCreationDate().getTime()));
1082
      stmt.setTimestamp(3, new Timestamp(submission.getCreationDate().getTime()));
1083
      stmt.setTimestamp(4, new Timestamp(submission.getLastUpdateDate().getTime()));
1083
      stmt.setTimestamp(4, new Timestamp(submission.getLastUpdateDate().getTime()));
[+20] [20] 37 lines
[+20] public void createSubmission(MSubmission submission, Connection conn) {
1121
  @Override
1121
  @Override
1122
  public boolean existsSubmission(long submissionId, Connection conn) {
1122
  public boolean existsSubmission(long submissionId, Connection conn) {
1123
    PreparedStatement stmt = null;
1123
    PreparedStatement stmt = null;
1124
    ResultSet rs = null;
1124
    ResultSet rs = null;
1125
    try {
1125
    try {
1126
      stmt = conn.prepareStatement(STMT_SELECT_SUBMISSION_CHECK);
1126
      stmt = conn.prepareStatement(STMT_SELECT_SQ_SUBMISSION_CHECK);
1127
      stmt.setLong(1, submissionId);
1127
      stmt.setLong(1, submissionId);
1128
      rs = stmt.executeQuery();
1128
      rs = stmt.executeQuery();
1129

    
   
1129

   
1130
      // Should be always valid in query with count
1130
      // Should be always valid in query with count
1131
      rs.next();
1131
      rs.next();
[+20] [20] 15 lines
[+20] public boolean existsSubmission(long submissionId, Connection conn) {
1147
  public void updateSubmission(MSubmission submission, Connection conn) {
1147
  public void updateSubmission(MSubmission submission, Connection conn) {
1148
    PreparedStatement stmt = null;
1148
    PreparedStatement stmt = null;
1149
    PreparedStatement deleteStmt = null;
1149
    PreparedStatement deleteStmt = null;
1150
    try {
1150
    try {
1151
      //  Update properties in main table
1151
      //  Update properties in main table
1152
      stmt = conn.prepareStatement(STMT_UPDATE_SUBMISSION);
1152
      stmt = conn.prepareStatement(STMT_UPDATE_SQ_SUBMISSION);
1153
      stmt.setString(1, submission.getStatus().name());
1153
      stmt.setString(1, submission.getStatus().name());
1154
      stmt.setTimestamp(2, new Timestamp(submission.getLastUpdateDate().getTime()));
1154
      stmt.setTimestamp(2, new Timestamp(submission.getLastUpdateDate().getTime()));
1155
      stmt.setString(3, submission.getExceptionInfo());
1155
      stmt.setString(3, submission.getExceptionInfo());
1156
      stmt.setString(4, submission.getExceptionStackTrace());
1156
      stmt.setString(4, submission.getExceptionStackTrace());
1157

    
   
1157

   
1158
      stmt.setLong(5, submission.getPersistenceId());
1158
      stmt.setLong(5, submission.getPersistenceId());
1159
      stmt.executeUpdate();
1159
      stmt.executeUpdate();
1160

    
   
1160

   
1161
      // Delete previous counters
1161
      // Delete previous counters
1162
      deleteStmt = conn.prepareStatement(STMT_DELETE_COUNTER_SUBMISSION);
1162
      deleteStmt = conn.prepareStatement(STMT_DELETE_SQ_COUNTER_SUBMISSION);
1163
      deleteStmt.setLong(1, submission.getPersistenceId());
1163
      deleteStmt.setLong(1, submission.getPersistenceId());
1164
      deleteStmt.executeUpdate();
1164
      deleteStmt.executeUpdate();
1165

    
   
1165

   
1166
      // Reinsert new counters if needed
1166
      // Reinsert new counters if needed
1167
      if(submission.getCounters() != null) {
1167
      if(submission.getCounters() != null) {
[+20] [20] 13 lines
[+20] public void updateSubmission(MSubmission submission, Connection conn) {
1181
   */
1181
   */
1182
  @Override
1182
  @Override
1183
  public void purgeSubmissions(Date threshold, Connection conn) {
1183
  public void purgeSubmissions(Date threshold, Connection conn) {
1184
     PreparedStatement stmt = null;
1184
     PreparedStatement stmt = null;
1185
    try {
1185
    try {
1186
      stmt = conn.prepareStatement(STMT_PURGE_SUBMISSIONS);
1186
      stmt = conn.prepareStatement(STMT_PURGE_SQ_SUBMISSIONS);
1187
      stmt.setTimestamp(1, new Timestamp(threshold.getTime()));
1187
      stmt.setTimestamp(1, new Timestamp(threshold.getTime()));
1188
      stmt.executeUpdate();
1188
      stmt.executeUpdate();
1189

    
   
1189

   
1190
    } catch (SQLException ex) {
1190
    } catch (SQLException ex) {
1191
      logException(ex, threshold);
1191
      logException(ex, threshold);
[+20] [20] 10 lines
[+20] public void purgeSubmissions(Date threshold, Connection conn) {
1202
  public List<MSubmission> findSubmissionsUnfinished(Connection conn) {
1202
  public List<MSubmission> findSubmissionsUnfinished(Connection conn) {
1203
    List<MSubmission> submissions = new LinkedList<MSubmission>();
1203
    List<MSubmission> submissions = new LinkedList<MSubmission>();
1204
    PreparedStatement stmt = null;
1204
    PreparedStatement stmt = null;
1205
    ResultSet rs = null;
1205
    ResultSet rs = null;
1206
    try {
1206
    try {
1207
      stmt = conn.prepareStatement(STMT_SELECT_SUBMISSION_UNFINISHED);
1207
      stmt = conn.prepareStatement(STMT_SELECT_SQ_SUBMISSION_UNFINISHED);
1208

    
   
1208

   
1209
      for(SubmissionStatus status : SubmissionStatus.unfinished()) {
1209
      for(SubmissionStatus status : SubmissionStatus.unfinished()) {
1210
        stmt.setString(1, status.name());
1210
        stmt.setString(1, status.name());
1211
        rs = stmt.executeQuery();
1211
        rs = stmt.executeQuery();
1212

    
   
1212

   
[+20] [20] 22 lines
[+20] public void purgeSubmissions(Date threshold, Connection conn) {
1235
  public List<MSubmission> findSubmissions(Connection conn) {
1235
  public List<MSubmission> findSubmissions(Connection conn) {
1236
    List<MSubmission> submissions = new LinkedList<MSubmission>();
1236
    List<MSubmission> submissions = new LinkedList<MSubmission>();
1237
    PreparedStatement stmt = null;
1237
    PreparedStatement stmt = null;
1238
    ResultSet rs = null;
1238
    ResultSet rs = null;
1239
    try {
1239
    try {
1240
      stmt = conn.prepareStatement(STMT_SELECT_SUBMISSIONS);
1240
      stmt = conn.prepareStatement(STMT_SELECT_SQ_SUBMISSIONS);
1241
      rs = stmt.executeQuery();
1241
      rs = stmt.executeQuery();
1242

    
   
1242

   
1243
      while(rs.next()) {
1243
      while(rs.next()) {
1244
        submissions.add(loadSubmission(rs, conn));
1244
        submissions.add(loadSubmission(rs, conn));
1245
      }
1245
      }
[+20] [20] 15 lines
[+20] public void purgeSubmissions(Date threshold, Connection conn) {
1261
  public List<MSubmission> findSubmissionsForJob(long jobId, Connection conn) {
1261
  public List<MSubmission> findSubmissionsForJob(long jobId, Connection conn) {
1262
    List<MSubmission> submissions = new LinkedList<MSubmission>();
1262
    List<MSubmission> submissions = new LinkedList<MSubmission>();
1263
    PreparedStatement stmt = null;
1263
    PreparedStatement stmt = null;
1264
    ResultSet rs = null;
1264
    ResultSet rs = null;
1265
    try {
1265
    try {
1266
      stmt = conn.prepareStatement(STMT_SELECT_SUBMISSIONS_FOR_JOB);
1266
      stmt = conn.prepareStatement(STMT_SELECT_SQ_SUBMISSIONS_FOR_JOB);
1267
      stmt.setLong(1, jobId);
1267
      stmt.setLong(1, jobId);
1268
      rs = stmt.executeQuery();
1268
      rs = stmt.executeQuery();
1269

    
   
1269

   
1270
      while(rs.next()) {
1270
      while(rs.next()) {
1271
        submissions.add(loadSubmission(rs, conn));
1271
        submissions.add(loadSubmission(rs, conn));
[+20] [20] 18 lines
[+20] public void purgeSubmissions(Date threshold, Connection conn) {
1290
  @Override
1290
  @Override
1291
  public MSubmission findSubmissionLastForJob(long jobId, Connection conn) {
1291
  public MSubmission findSubmissionLastForJob(long jobId, Connection conn) {
1292
    PreparedStatement stmt = null;
1292
    PreparedStatement stmt = null;
1293
    ResultSet rs = null;
1293
    ResultSet rs = null;
1294
    try {
1294
    try {
1295
      stmt = conn.prepareStatement(STMT_SELECT_SUBMISSIONS_FOR_JOB);
1295
      stmt = conn.prepareStatement(STMT_SELECT_SQ_SUBMISSIONS_FOR_JOB);
1296
      stmt.setLong(1, jobId);
1296
      stmt.setLong(1, jobId);
1297
      stmt.setMaxRows(1);
1297
      stmt.setMaxRows(1);
1298
      rs = stmt.executeQuery();
1298
      rs = stmt.executeQuery();
1299

    
   
1299

   
1300
      if(!rs.next()) {
1300
      if(!rs.next()) {
[+20] [20] 20 lines
[+20] public MSubmission findSubmissionLastForJob(long jobId, Connection conn) {
1321
   */
1321
   */
1322
  private void createSubmissionCounters(long submissionId, Counters counters, Connection conn) throws SQLException {
1322
  private void createSubmissionCounters(long submissionId, Counters counters, Connection conn) throws SQLException {
1323
    PreparedStatement stmt = null;
1323
    PreparedStatement stmt = null;
1324

    
   
1324

   
1325
    try {
1325
    try {
1326
      stmt = conn.prepareStatement(STMT_INSERT_COUNTER_SUBMISSION);
1326
      stmt = conn.prepareStatement(STMT_INSERT_SQ_COUNTER_SUBMISSION);
1327

    
   
1327

   
1328
      for(CounterGroup group : counters) {
1328
      for(CounterGroup group : counters) {
1329
        long groupId = getCounterGroupId(group, conn);
1329
        long groupId = getCounterGroupId(group, conn);
1330

    
   
1330

   
1331
        for(Counter counter: group) {
1331
        for(Counter counter: group) {
[+20] [20] 25 lines
[+20] [+] private long getCounterGroupId(CounterGroup group, Connection conn) throws SQLException {
1357
    PreparedStatement insert = null;
1357
    PreparedStatement insert = null;
1358
    ResultSet rsSelect = null;
1358
    ResultSet rsSelect = null;
1359
    ResultSet rsInsert = null;
1359
    ResultSet rsInsert = null;
1360

    
   
1360

   
1361
    try {
1361
    try {
1362
      select = conn.prepareStatement(STMT_SELECT_COUNTER_GROUP);
1362
      select = conn.prepareStatement(STMT_SELECT_SQ_COUNTER_GROUP);
1363
      select.setString(1, group.getName());
1363
      select.setString(1, group.getName());
1364

    
   
1364

   
1365
      rsSelect = select.executeQuery();
1365
      rsSelect = select.executeQuery();
1366

    
   
1366

   
1367
      if(rsSelect.next()) {
1367
      if(rsSelect.next()) {
1368
        return rsSelect.getLong(1);
1368
        return rsSelect.getLong(1);
1369
      }
1369
      }
1370

    
   
1370

   
1371
      insert = conn.prepareStatement(STMT_INSERT_COUNTER_GROUP, Statement.RETURN_GENERATED_KEYS);
1371
      insert = conn.prepareStatement(STMT_INSERT_SQ_COUNTER_GROUP, Statement.RETURN_GENERATED_KEYS);
1372
      insert.setString(1, group.getName());
1372
      insert.setString(1, group.getName());
1373
      insert.executeUpdate();
1373
      insert.executeUpdate();
1374

    
   
1374

   
1375
      rsInsert = insert.getGeneratedKeys();
1375
      rsInsert = insert.getGeneratedKeys();
1376

    
   
1376

   
[+20] [20] 21 lines
[+20] [+] private long getCounterId(Counter counter, Connection conn) throws SQLException {
1398
    PreparedStatement insert = null;
1398
    PreparedStatement insert = null;
1399
    ResultSet rsSelect = null;
1399
    ResultSet rsSelect = null;
1400
    ResultSet rsInsert = null;
1400
    ResultSet rsInsert = null;
1401

    
   
1401

   
1402
    try {
1402
    try {
1403
      select = conn.prepareStatement(STMT_SELECT_COUNTER);
1403
      select = conn.prepareStatement(STMT_SELECT_SQ_COUNTER);
1404
      select.setString(1, counter.getName());
1404
      select.setString(1, counter.getName());
1405

    
   
1405

   
1406
      rsSelect = select.executeQuery();
1406
      rsSelect = select.executeQuery();
1407

    
   
1407

   
1408
      if(rsSelect.next()) {
1408
      if(rsSelect.next()) {
1409
        return rsSelect.getLong(1);
1409
        return rsSelect.getLong(1);
1410
      }
1410
      }
1411

    
   
1411

   
1412
      insert = conn.prepareStatement(STMT_INSERT_COUNTER, Statement.RETURN_GENERATED_KEYS);
1412
      insert = conn.prepareStatement(STMT_INSERT_SQ_COUNTER, Statement.RETURN_GENERATED_KEYS);
1413
      insert.setString(1, counter.getName());
1413
      insert.setString(1, counter.getName());
1414
      insert.executeUpdate();
1414
      insert.executeUpdate();
1415

    
   
1415

   
1416
      rsInsert = insert.getGeneratedKeys();
1416
      rsInsert = insert.getGeneratedKeys();
1417

    
   
1417

   
[+20] [20] 37 lines
[+20] [+] private MSubmission loadSubmission(ResultSet rs, Connection conn) throws SQLException {
1455

    
   
1455

   
1456
  private Counters loadCountersSubmission(long submissionId, Connection conn) throws SQLException {
1456
  private Counters loadCountersSubmission(long submissionId, Connection conn) throws SQLException {
1457
    PreparedStatement stmt = null;
1457
    PreparedStatement stmt = null;
1458
    ResultSet rs = null;
1458
    ResultSet rs = null;
1459
    try {
1459
    try {
1460
      stmt = conn.prepareStatement(STMT_SELECT_COUNTER_SUBMISSION);
1460
      stmt = conn.prepareStatement(STMT_SELECT_SQ_COUNTER_SUBMISSION);
1461
      stmt.setLong(1, submissionId);
1461
      stmt.setLong(1, submissionId);
1462
      rs = stmt.executeQuery();
1462
      rs = stmt.executeQuery();
1463

    
   
1463

   
1464
      Counters counters = new Counters();
1464
      Counters counters = new Counters();
1465

    
   
1465

   
[+20] [20] 32 lines
[+20] private Counters loadCountersSubmission(long submissionId, Connection conn) throws SQLException {
1498
    PreparedStatement inputFetchStmt = null;
1498
    PreparedStatement inputFetchStmt = null;
1499

    
   
1499

   
1500
    try {
1500
    try {
1501
      rsConnection = stmt.executeQuery();
1501
      rsConnection = stmt.executeQuery();
1502

    
   
1502

   
1503
      formConnectorFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_CONNECTOR);
1503
      formConnectorFetchStmt = conn.prepareStatement(STMT_FETCH_SQ_FORM_CONNECTOR);
1504
      formFrameworkFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_FRAMEWORK);
1504
      formFrameworkFetchStmt = conn.prepareStatement(STMT_FETCH_SQ_FORM_FRAMEWORK);
1505
      inputFetchStmt = conn.prepareStatement(STMT_FETCH_CONNECTION_INPUT);
1505
      inputFetchStmt = conn.prepareStatement(STMT_FETCH_SQ_CONNECTION_INPUT);
1506

    
   
1506

   
1507
      while(rsConnection.next()) {
1507
      while(rsConnection.next()) {
1508
        long id = rsConnection.getLong(1);
1508
        long id = rsConnection.getLong(1);
1509
        String name = rsConnection.getString(2);
1509
        String name = rsConnection.getString(2);
1510
        long connectorId = rsConnection.getLong(3);
1510
        long connectorId = rsConnection.getLong(3);
[+20] [20] 49 lines
[+20] private Counters loadCountersSubmission(long submissionId, Connection conn) throws SQLException {
1560
    PreparedStatement inputFetchStmt = null;
1560
    PreparedStatement inputFetchStmt = null;
1561

    
   
1561

   
1562
    try {
1562
    try {
1563
      rsJob = stmt.executeQuery();
1563
      rsJob = stmt.executeQuery();
1564

    
   
1564

   
1565
      formConnectorFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_CONNECTOR);
1565
      formConnectorFetchStmt = conn.prepareStatement(STMT_FETCH_SQ_FORM_CONNECTOR);
1566
      formFrameworkFetchStmt = conn.prepareStatement(STMT_FETCH_FORM_FRAMEWORK);
1566
      formFrameworkFetchStmt = conn.prepareStatement(STMT_FETCH_SQ_FORM_FRAMEWORK);
1567
      inputFetchStmt = conn.prepareStatement(STMT_FETCH_JOB_INPUT);
1567
      inputFetchStmt = conn.prepareStatement(STMT_FETCH_SQ_JOB_INPUT);
1568

    
   
1568

   
1569
      while(rsJob.next()) {
1569
      while(rsJob.next()) {
1570
        long connectorId = rsJob.getLong(1);
1570
        long connectorId = rsJob.getLong(1);
1571
        long id = rsJob.getLong(2);
1571
        long id = rsJob.getLong(2);
1572
        String name = rsJob.getString(3);
1572
        String name = rsJob.getString(3);
[+20] [20] 410 lines
repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java
Revision b2cd6cc New Change
 
  1. repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java: Loading...
  2. repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaQuery.java: Loading...