Revision 667
Added by berkley over 23 years ago
MetacatReplication.java | ||
---|---|---|
179 | 179 |
try |
180 | 180 |
{ |
181 | 181 |
Connection conn = util.openDBConnection(); |
182 |
PreparedStatement pstmt; |
|
182 |
PreparedStatement pstmt = null;
|
|
183 | 183 |
if(subaction.equals("add")) |
184 | 184 |
{ |
185 | 185 |
String replicate = ((String[])params.get("replicate"))[0]; |
... | ... | |
249 | 249 |
} |
250 | 250 |
out.println("</table></body></html>"); |
251 | 251 |
} |
252 |
pstmt.close(); |
|
252 | 253 |
conn.close(); |
253 | 254 |
} |
254 | 255 |
catch(Exception e) |
... | ... | |
538 | 539 |
|
539 | 540 |
doclist.append("</updates></replication>"); |
540 | 541 |
MetaCatUtil.debugMessage("doclist: " + doclist.toString()); |
542 |
pstmt.close(); |
|
541 | 543 |
conn.close(); |
542 | 544 |
response.setContentType("text/xml"); |
543 | 545 |
out.println(doclist.toString()); |
... | ... | |
575 | 577 |
HttpServletResponse response, |
576 | 578 |
boolean printFlag) |
577 | 579 |
{ |
580 |
Connection conn = null; |
|
581 |
PreparedStatement pstmt = null; |
|
578 | 582 |
try |
579 | 583 |
{ |
580 |
Connection conn = util.openDBConnection();
|
|
581 |
PreparedStatement pstmt = conn.prepareStatement("select entry_type, " +
|
|
584 |
conn = util.openDBConnection(); |
|
585 |
pstmt = conn.prepareStatement("select entry_type, " + |
|
582 | 586 |
"source_doctype, target_doctype, public_id, " + |
583 | 587 |
"system_id from xml_catalog"); |
584 | 588 |
pstmt.execute(); |
... | ... | |
604 | 608 |
response.setContentType("text/xml"); |
605 | 609 |
out.println(sb.toString()); |
606 | 610 |
} |
611 |
pstmt.close(); |
|
607 | 612 |
return sb.toString(); |
608 | 613 |
} |
609 | 614 |
catch(Exception e) |
610 | 615 |
{ |
616 |
try |
|
617 |
{ |
|
618 |
pstmt.close(); |
|
619 |
conn.close(); |
|
620 |
} |
|
621 |
catch(Exception ee) |
|
622 |
{} |
|
611 | 623 |
System.out.println("error in handleGetCatalogRequest: " + e.getMessage()); |
612 | 624 |
e.printStackTrace(System.out); |
613 | 625 |
} |
... | ... | |
685 | 697 |
//System.out.println("server: " + rs.getString(1)); |
686 | 698 |
return rs.getString(1); |
687 | 699 |
} |
700 |
pstmt.close(); |
|
688 | 701 |
conn.close(); |
689 | 702 |
} |
690 | 703 |
catch(Exception e) |
... | ... | |
704 | 717 |
*/ |
705 | 718 |
public static int getServerCode(String server) throws Exception |
706 | 719 |
{ |
720 |
Connection conn = null; |
|
721 |
PreparedStatement pstmt = null; |
|
707 | 722 |
try |
708 | 723 |
{ |
709 |
Connection conn = util.openDBConnection();
|
|
710 |
PreparedStatement pstmt = conn.prepareStatement("select serverid from " +
|
|
724 |
conn = util.openDBConnection(); |
|
725 |
pstmt = conn.prepareStatement("select serverid from " + |
|
711 | 726 |
"xml_replication where server " + |
712 | 727 |
"like '" + server + "'"); |
713 | 728 |
pstmt.execute(); |
... | ... | |
715 | 730 |
boolean tablehasrows = rs.next(); |
716 | 731 |
int serverCode = 0; |
717 | 732 |
if(tablehasrows) |
718 |
{ |
|
719 |
return rs.getInt(1); |
|
733 |
{ |
|
734 |
int ret = rs.getInt(1); |
|
735 |
pstmt.close(); |
|
736 |
conn.close(); |
|
737 |
return ret; |
|
720 | 738 |
} |
721 | 739 |
else |
722 | 740 |
{ |
741 |
pstmt.close(); |
|
742 |
conn.close(); |
|
723 | 743 |
return 0; |
724 | 744 |
} |
725 | 745 |
} |
... | ... | |
727 | 747 |
{ |
728 | 748 |
throw e; |
729 | 749 |
} |
750 |
finally |
|
751 |
{ |
|
752 |
try |
|
753 |
{ |
|
754 |
pstmt.close(); |
|
755 |
conn.close(); |
|
756 |
} |
|
757 |
catch(Exception ee) {} |
|
758 |
} |
|
730 | 759 |
} |
731 | 760 |
|
732 | 761 |
/** |
... | ... | |
783 | 812 |
*/ |
784 | 813 |
public static boolean replToServer(String server) |
785 | 814 |
{ |
815 |
Connection conn = null; |
|
816 |
PreparedStatement pstmt = null; |
|
786 | 817 |
try |
787 | 818 |
{ |
788 |
Connection conn = util.openDBConnection();
|
|
789 |
PreparedStatement pstmt = conn.prepareStatement("select replicate from " +
|
|
790 |
"xml_replication where server like '" + |
|
791 |
server + "'"); |
|
819 |
conn = util.openDBConnection(); |
|
820 |
pstmt = conn.prepareStatement("select replicate from " + |
|
821 |
"xml_replication where server like '" +
|
|
822 |
server + "'");
|
|
792 | 823 |
pstmt.execute(); |
793 | 824 |
ResultSet rs = pstmt.getResultSet(); |
794 | 825 |
boolean tablehasrows = rs.next(); |
... | ... | |
797 | 828 |
int i = rs.getInt(1); |
798 | 829 |
if(i == 1) |
799 | 830 |
{ |
831 |
pstmt.close(); |
|
832 |
conn.close(); |
|
800 | 833 |
return true; |
801 | 834 |
} |
802 | 835 |
else |
803 | 836 |
{ |
837 |
pstmt.close(); |
|
838 |
conn.close(); |
|
804 | 839 |
return false; |
805 | 840 |
} |
806 | 841 |
} |
... | ... | |
809 | 844 |
{ |
810 | 845 |
System.out.println("error in replToServer: " + e.getMessage()); |
811 | 846 |
} |
847 |
finally |
|
848 |
{ |
|
849 |
try |
|
850 |
{ |
|
851 |
pstmt.close(); |
|
852 |
conn.close(); |
|
853 |
} |
|
854 |
catch(Exception ee) |
|
855 |
{} |
|
856 |
} |
|
812 | 857 |
return false; |
813 | 858 |
//the default if this server does not exist is to not replicate to it. |
814 | 859 |
} |
Also available in: Unified diff
closed all preparedStatement variables