01: /*
02: This file is part of the PolePosition database benchmark
03: http://www.polepos.org
04:
05: This program is free software; you can redistribute it and/or
06: modify it under the terms of the GNU General Public License
07: as published by the Free Software Foundation; either version 2
08: of the License, or (at your option) any later version.
09:
10: This program is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13: GNU General Public License for more details.
14:
15: You should have received a copy of the GNU General Public
16: License along with this program; if not, write to the Free
17: Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
18: MA 02111-1307, USA. */
19:
20: package org.polepos.teams.jdbc;
21:
22: import java.io.*;
23:
24: public class Jdbc {
25:
26: /**
27: * Help some of the databases to get a home.
28: */
29: private static final String[] CREATE_DIRS = new String[] {
30: "data/derby", "data/mckoi" };
31:
32: private final static JdbcSettings sSettings = new JdbcSettings();
33:
34: public static JdbcSettings settings() {
35: return sSettings;
36: }
37:
38: //
39: // make a copy of the default mckoi.conf so that mckoi JDBC can start
40: //
41: static {
42:
43: for (String dir : CREATE_DIRS) {
44: new File(dir).mkdirs();
45: }
46:
47: try {
48:
49: File cfg = new File("mckoi.conf");
50: if (!cfg.exists()) {
51: InputStream in = JdbcSettings.class.getClassLoader()
52: .getResourceAsStream("mckoi.conf");
53: OutputStream out = new FileOutputStream(cfg);
54:
55: // Transfer bytes from in to out
56: byte[] buf = new byte[1024];
57: int len;
58: while ((len = in.read(buf)) > 0) {
59: out.write(buf, 0, len);
60: }
61: in.close();
62: out.close();
63: }
64: } catch (FileNotFoundException fnfex) {
65: fnfex.printStackTrace();
66: } catch (IOException ioex) {
67: ioex.printStackTrace();
68: }
69: }
70:
71: }
|