Mercurial > dive4elements > framework
comparison artifact-database/src/main/java/de/intevation/artifactdatabase/Backend.java @ 145:c0d025df722d
Enable backend to delete users
artifacts/trunk@1370 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 02 Mar 2011 17:47:20 +0000 |
parents | 5369582d4fbf |
children | 967dc552455d |
comparison
equal
deleted
inserted
replaced
144:5369582d4fbf | 145:c0d025df722d |
---|---|
820 Document role | 820 Document role |
821 ) { | 821 ) { |
822 Connection connection = null; | 822 Connection connection = null; |
823 PreparedStatement stmnt_next_id = null; | 823 PreparedStatement stmnt_next_id = null; |
824 PreparedStatement stmnt_insert = null; | 824 PreparedStatement stmnt_insert = null; |
825 ResultSet res_id = null; | 825 ResultSet result = null; |
826 | 826 |
827 String identifier = newIdentifier(); | 827 String identifier = newIdentifier(); |
828 | 828 |
829 DataSource dataSource = DBConnection.getDataSource(); | 829 DataSource dataSource = DBConnection.getDataSource(); |
830 try { | 830 try { |
833 connection.setAutoCommit(false); | 833 connection.setAutoCommit(false); |
834 | 834 |
835 stmnt_next_id = connection.prepareStatement(SQL_USERS_NEXT_ID); | 835 stmnt_next_id = connection.prepareStatement(SQL_USERS_NEXT_ID); |
836 stmnt_insert = connection.prepareStatement(SQL_USERS_INSERT); | 836 stmnt_insert = connection.prepareStatement(SQL_USERS_INSERT); |
837 | 837 |
838 res_id = stmnt_next_id.executeQuery(); | 838 result = stmnt_next_id.executeQuery(); |
839 | 839 |
840 if (!res_id.next()) { | 840 if (!res_id.next()) { |
841 throw new RuntimeException("No id generated"); | 841 throw new RuntimeException("No id generated"); |
842 } | 842 } |
843 | 843 |
844 int id = res_id.getInt(1); | 844 int id = result.getInt(1); |
845 | 845 |
846 stmnt_insert.setInt(1, id); | 846 stmnt_insert.setInt(1, id); |
847 stmnt_insert.setString(2, identifier); | 847 stmnt_insert.setString(2, identifier); |
848 stmnt_insert.setString(3, name); | 848 stmnt_insert.setString(3, name); |
849 | 849 |
871 } | 871 } |
872 catch (SQLException sqle) { | 872 catch (SQLException sqle) { |
873 logger.error(sqle.getLocalizedMessage(), sqle); | 873 logger.error(sqle.getLocalizedMessage(), sqle); |
874 } | 874 } |
875 finally { | 875 finally { |
876 if (res_id != null) { | 876 if (result != null) { |
877 try { res_id.close(); } | 877 try { result.close(); } |
878 catch (SQLException sqle) {} | 878 catch (SQLException sqle) {} |
879 } | 879 } |
880 if (stmnt_insert != null) { | 880 if (stmnt_insert != null) { |
881 try { stmnt_insert.close(); } | 881 try { stmnt_insert.close(); } |
882 catch (SQLException sqle) {} | 882 catch (SQLException sqle) {} |