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
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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