Project

General

Profile

« Previous | Next » 

Revision 9463

Added by Jing Tao almost 9 years ago

Close some prepared sql statement in the summarize method.

View differences:

src/edu/ucsb/nceas/metacat/annotation/DatapackageSummarizer.java
501 501
	private void summarize(List<Identifier> identifiers) throws SQLException {
502 502
		
503 503
		DBConnection dbconn = null;
504

  
504
		int serialNumber = -1;
505
		PreparedStatement dropStatement = null;
506
		PreparedStatement createStatement = null;
507
		PreparedStatement insertStatement = null;
505 508
		try {
506 509
			dbconn = DBConnectionPool.getDBConnection("DatapackageSummarizer.summarize");
507
			
508
			PreparedStatement dropStatement = dbconn.prepareStatement("DROP TABLE IF EXISTS entity_summary");
510
			serialNumber = dbconn.getCheckOutSerialNumber();
511
			dropStatement = dbconn.prepareStatement("DROP TABLE IF EXISTS entity_summary");
509 512
			dropStatement.execute();
510 513
	
511
			PreparedStatement createStatement = dbconn.prepareStatement(
514
			createStatement = dbconn.prepareStatement(
512 515
					"CREATE TABLE entity_summary (" +
513 516
					"guid text, " +
514 517
					"title text, " +
......
524 527
					")");
525 528
			createStatement.execute();
526 529
			
527
			PreparedStatement insertStatement = dbconn.prepareStatement(
530
			insertStatement = dbconn.prepareStatement(
528 531
					"INSERT INTO entity_summary " +
529 532
					"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
530 533
			
......
590 593
			// just throw it
591 594
			throw sqle;
592 595
		} finally {
593
			if (dbconn != null) {
594
				DBConnectionPool.returnDBConnection(dbconn, 0);
595
				dbconn.close();
596
			}
596
		    try {
597
		        if(dropStatement != null) {
598
		            dropStatement.close();
599
		        }
600
		        if(createStatement != null) {
601
		            createStatement.close();
602
		        }
603
		        if(insertStatement != null) {
604
		            insertStatement.close();
605
		        }
606
		    } catch (Exception e) {
607
		        logMetacat.warn("couldn't close the prepared statement "+e.getMessage());
608
		    } finally {
609
		        if (dbconn != null) {
610
	                DBConnectionPool.returnDBConnection(dbconn, serialNumber);
611
	                //dbconn.close();
612
	            }
613
		    }
614
			
597 615
		}
598 616
	}
599 617
	

Also available in: Unified diff