1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements.  See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership.  The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License.  You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied.  See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 module hunt.shiro.util.JdbcUtils;
20 
21 // import java.sql.Connection;
22 // import java.sql.ResultSet;
23 // import java.sql.SQLException;
24 // import java.sql.Statement;
25 
26 // import hunt.logging.Logger;
27 
28 // /**
29 //  * A set of static helper methods for managing JDBC API objects.
30 //  * <p/>
31 //  * <em>Note:</em> Some parts of this class were copied from the Spring Framework and then modified.
32 //  * They were copied here to prevent Spring dependencies in the Shiro core API.  The original license conditions
33 //  * (Apache 2.0) have been maintained.
34 //  *
35 //  */
36 // class JdbcUtils {
37 
38 //     /** Private internal log instance. */
39 
40 
41 //     /**
42 //      * Private constructor to prevent instantiation.
43 //      */
44 //     private this() {
45 //     }
46 
47 //     /**
48 //      * Close the given JDBC Connection and ignore any thrown exception.
49 //      * This is useful for typical finally blocks in manual JDBC code.
50 //      *
51 //      * @param connection the JDBC Connection to close (may be <tt>null</tt>)
52 //      */
53 //      static void closeConnection(Connection connection) {
54 //         if (connection !is null) {
55 //             try {
56 //                 connection.close();
57 //             } catch (SQLException ex) {
58 //                 version(HUNT_DEBUG) {
59 //                     tracef("Could not close JDBC Connection", ex);
60 //                 }
61 //             } catch (Throwable ex) {
62 //                 version(HUNT_DEBUG) {
63 //                     tracef("Unexpected exception on closing JDBC Connection", ex);
64 //                 }
65 //             }
66 //         }
67 //     }
68 
69 //     /**
70 //      * Close the given JDBC Statement and ignore any thrown exception.
71 //      * This is useful for typical finally blocks in manual JDBC code.
72 //      *
73 //      * @param statement the JDBC Statement to close (may be <tt>null</tt>)
74 //      */
75 //      static void closeStatement(Statement statement) {
76 //         if (statement !is null) {
77 //             try {
78 //                 statement.close();
79 //             } catch (SQLException ex) {
80 //                 version(HUNT_DEBUG) {
81 //                     tracef("Could not close JDBC Statement", ex);
82 //                 }
83 //             } catch (Throwable ex) {
84 //                 version(HUNT_DEBUG) {
85 //                     tracef("Unexpected exception on closing JDBC Statement", ex);
86 //                 }
87 //             }
88 //         }
89 //     }
90 
91 //     /**
92 //      * Close the given JDBC ResultSet and ignore any thrown exception.
93 //      * This is useful for typical finally blocks in manual JDBC code.
94 //      *
95 //      * @param rs the JDBC ResultSet to close (may be <tt>null</tt>)
96 //      */
97 //      static void closeResultSet(ResultSet rs) {
98 //         if (rs !is null) {
99 //             try {
100 //                 rs.close();
101 //             } catch (SQLException ex) {
102 //                 version(HUNT_DEBUG) {
103 //                     tracef("Could not close JDBC ResultSet", ex);
104 //                 }
105 //             } catch (Throwable ex) {
106 //                 version(HUNT_DEBUG) {
107 //                     tracef("Unexpected exception on closing JDBC ResultSet", ex);
108 //                 }
109 //             }
110 //         }
111 //     }
112 
113 // }