HsqldbStandaloneDataSourceComponent.java

biz/hammurapi/sql/hsqldb/HsqldbStandaloneDataSourceComponent.java

Violations

Inspector Message Severity Location
Java Inspector 048 Copyrights information should be present in each file. 1
Java Inspector 087 Chain exceptions. If exception is thrown from an exception handler (wrapping exceptions), pass the cause exception to the new exception constructor. 2 81:31
Java Inspector 089 Undocumented top level type 2 38:1
Java Inspector 089 Undocumented constructor 2 42:9
Java Inspector 089 Undocumented method 2 46:9
Java Inspector 089 Undocumented method 2 55:9
Java Inspector 089 Undocumented method 2 60:9
Java Inspector 089 Undocumented method 2 66:49
Java Inspector 089 Undocumented method 2 85:9
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 48:57
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 57:62
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 77:58
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 79:58
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 81:58

Source code

1/*
2 * hgcommons 9
3 * Hammurapi Group Common Library
4 * Copyright (C) 2003 Hammurapi Group
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * URL: http://www.hammurapi.biz/hammurapi-biz/ef/xmenu/hammurapi-group/products/products/hgcommons/index.html
21 * e-Mail: support@hammurapi.biz
22 */
23package biz.hammurapi.sql.hsqldb;
24
25import java.io.IOException;
26import java.sql.SQLException;
27
28import org.w3c.dom.Element;
29import org.w3c.dom.Node;
30
31import biz.hammurapi.CarryOverException;
32import biz.hammurapi.config.ConfigurationException;
33import biz.hammurapi.config.Context;
34import biz.hammurapi.sql.SQLProcessor;
35import biz.hammurapi.sql.Transaction;
36
37
38public class HsqldbStandaloneDataSourceComponent extends HsqldbDataSourceComponent {
39
40 private HsqldbStandaloneDataSource master;
41
42 public HsqldbStandaloneDataSourceComponent() {
43 super();
44 }
45
46 public Object getMaster() {
47 if (master==null) {
48 throw new IllegalStateException("Not yet started");
49 }
50 return master;
51 }
52
53 private String location;
54
55 public void configure(Node configNode, Context context, ClassLoader classLoader) throws ConfigurationException {
56 super.configure(configNode, context, classLoader);
57 location=((Element) configNode).getAttribute("location");
58 }
59
60 public void start() throws ConfigurationException {
61 try {
62 master=new HsqldbStandaloneDataSource(
63 location,
64 new Transaction() {
65
66 public boolean execute(SQLProcessor processor) throws SQLException {
67 try {
68 processor.executeScript(getReader());
69 } catch (IOException e) {
70 throw new CarryOverException(e);
71 }
72 return true;
73 }
74
75 });
76 } catch (ClassNotFoundException e) {
77 throw new ConfigurationException("Driver class not found", e);
78 } catch (SQLException e) {
79 throw new ConfigurationException("Could not initialize database: "+e, e);
80 } catch (CarryOverException e) {
81 throw new ConfigurationException("Could not initialize databse: "+e.getCause(), e.getCause());
82 }
83 }
84
85 public void stop() throws ConfigurationException {
86 if (master!=null) {
87 master.shutdown();
88 }
89 }
90}
91