2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.apache.shale.examples.sqlbrowser;
21
22 import java.sql.Connection;
23 import java.sql.SQLException;
24 import org.apache.derby.jdbc.EmbeddedDataSource;
25
26 /***
27 * <p>Trivial implementation of <code>DataSource</code> that wraps a data source
28 * provided by Derby, and provides a shutdown hook.</p>
29 */
30 public class InternalDataSource extends EmbeddedDataSource {
31
32
33
34
35
36 /***
37 * <p>Construct a connection pool for the specified URL.</p>
38 */
39 public InternalDataSource(String url) throws SQLException {
40
41
42 setDatabaseName(url);
43 setCreateDatabase("create");
44
45 }
46
47
48
49
50
51 /***
52 * <p>Cause the embedded Derby database to be shut down.</p>
53 */
54 public void shutdown() throws SQLException {
55
56 setShutdownDatabase("shutdown");
57 Connection conn = null;
58 try {
59 conn = getConnection();
60 } catch (SQLException e) {
61 ;
62 } finally {
63 try {
64 if (conn != null) {
65 conn.close();
66 }
67 } catch (SQLException e) {
68 ;
69 }
70 }
71
72 }
73
74
75 }