HsqldbService.java

biz/hammurapi/sql/hsqldb/HsqldbService.java

Violations

Inspector Message Severity Location
Java Inspector 048 Copyrights information should be present in each file. 1
Java Inspector 068 Do not use System.out and System.err to output logging messages. Use loggers instead. 2 44:51
Java Inspector 068 Do not use System.out and System.err to output logging messages. Use loggers instead. 2 51:51
Java Inspector 089 Method is not properly documented 2 21:9
Java Inspector 089 Parameter args is not documented 2 21:9
Java Inspector 089 Undocumented exception Exception 2 21:9
Java Inspector 025 Avoid hardwired numeric literals. Allowed literals: [1, -1, 0] 3 31:45
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 22:39
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 24:98
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 44:52
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 49:39
Java Inspector 026 Avoid hardwired string literals. Allowed literals: [] 3 51:52

Source code

1package biz.hammurapi.sql.hsqldb;
2
3import org.hsqldb.Server;
4import org.hsqldb.ServerConfiguration;
5import org.hsqldb.ServerConstants;
6import org.hsqldb.lib.FileUtil;
7import org.hsqldb.persist.HsqlProperties;
8
9/**
10 * Helper class to start HSQLDB server as Windows service.
11 * @author Pavel
12 *
13 */
14public class HsqldbService {
15
16 private static Server server;
17
18 /**
19 * @param args
20 */
21 public static void main(String[] args) throws Exception {
22 if (args.length==0 || "start".equals(args[0])) {
23 if (server==null) {
24 String propsPath = FileUtil.getDefaultInstance().canonicalOrAbsolutePath("server");
25 HsqlProperties fileProps = ServerConfiguration.getPropertiesFromFile(propsPath);
26 HsqlProperties props = fileProps == null ? new HsqlProperties() : fileProps;
27 HsqlProperties stringProps = HsqlProperties.argArrayToProps(args, ServerConstants.SC_KEY_PREFIX);
28
29 if (stringProps != null) {
30 if (stringProps.getErrorKeys().length != 0) {
31 System.exit(2);
32 }
33
34 props.addProperties(stringProps);
35 }
36
37 ServerConfiguration.translateDefaultDatabaseProperty(props);
38 ServerConfiguration.translateDefaultNoSystemExitProperty(props);
39
40 server = new Server();
41 server.setProperties(props);
42 server.start();
43 } else {
44 System.err.println("Server is already running.");
45 System.exit(1);
46 }
47 }
48
49 if (args.length!=0 && "stop".equals(args[0])) {
50 if (server==null) {
51 System.err.println("Server is not running.");
52 System.exit(1);
53 } else {
54 server.shutdown();
55 }
56 }
57 }
58
59}
60