KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > util > JdbcUtils


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.util;
6
7 import java.sql.Connection JavaDoc;
8 import java.sql.ResultSet JavaDoc;
9 import java.sql.SQLException JavaDoc;
10 import java.sql.Statement JavaDoc;
11
12 public class JdbcUtils {
13     
14     public static void closeSilently(Statement JavaDoc stat) {
15         if(stat != null) {
16             try {
17                 stat.close();
18             } catch(SQLException JavaDoc e) {
19                 // ignore
20
}
21         }
22     }
23
24     public static void closeSilently(Connection JavaDoc conn) {
25         if(conn != null) {
26             try {
27                 conn.close();
28             } catch(SQLException JavaDoc e) {
29                 // ignore
30
}
31         }
32     }
33
34     public static void closeSilently(ResultSet JavaDoc rs) {
35         if(rs != null) {
36             try {
37                 rs.close();
38             } catch(SQLException JavaDoc e) {
39                 // ignore
40
}
41         }
42     }
43     
44     public static ResultSet JavaDoc getGeneratedKeys(Statement JavaDoc stat) throws SQLException JavaDoc {
45         ResultSet JavaDoc rs = null;
46 //#ifdef JDK14
47
rs = stat.getGeneratedKeys();
48 //#endif
49
return rs;
50     }
51
52 }
53
Popular Tags