KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > scriptella > jdbc > JdbcUtils


1 /*
2  * Copyright 2006-2007 The Scriptella Project Team.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package scriptella.jdbc;
17
18 import java.sql.Connection JavaDoc;
19 import java.sql.ResultSet JavaDoc;
20 import java.sql.SQLException JavaDoc;
21 import java.sql.Statement JavaDoc;
22
23
24 /**
25  * Utility class JDBC related operations.
26  *
27  * @author Fyodor Kupolov
28  * @version 1.0
29  */

30 public final class JdbcUtils {
31     private JdbcUtils() {
32     }
33
34     /**
35      * Silently closes a connection.
36      * @param con connection to close. Nulls allowed.
37      */

38     public static void closeSilent(final Connection JavaDoc con) {
39         try {
40             if (con != null) {
41                 con.close();
42             }
43         } catch (SQLException JavaDoc e) {
44         }
45     }
46
47     /**
48      * Silently closes a statement.
49      * @param s statement to close. Nulls allowed.
50      */

51     public static void closeSilent(final Statement JavaDoc s) {
52         try {
53             if (s != null) {
54                 s.close();
55             }
56         } catch (SQLException JavaDoc e) {
57         }
58     }
59
60     /**
61      * Silently closes a result set.
62      * @param rs result set to close. Nulls allowed.
63      */

64     public static void closeSilent(final ResultSet JavaDoc rs) {
65         try {
66             if (rs != null) {
67                 rs.close();
68             }
69         } catch (SQLException JavaDoc e) {
70         }
71     }
72     
73 }
74
Popular Tags