KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > polepos > teams > jdbc > Jdbc


1 /*
2 This file is part of the PolePosition database benchmark
3 http://www.polepos.org
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
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 JavaDoc[] CREATE_DIRS = new String JavaDoc[]{
30         "data/derby",
31         "data/mckoi"
32     };
33
34     private final static JdbcSettings sSettings = new JdbcSettings();
35
36     public static JdbcSettings settings() {
37         return sSettings;
38     }
39
40     //
41
// make a copy of the default mckoi.conf so that mckoi JDBC can start
42
//
43
static {
44         
45         for(String JavaDoc dir : CREATE_DIRS){
46             new File(dir).mkdirs();
47         }
48         
49         
50         try {
51
52             File cfg = new File("mckoi.conf");
53             if (!cfg.exists()) {
54                 InputStream in = JdbcSettings.class.getClassLoader().getResourceAsStream(
55                     "mckoi.conf");
56                 OutputStream out = new FileOutputStream(cfg);
57
58                 // Transfer bytes from in to out
59
byte[] buf = new byte[1024];
60                 int len;
61                 while ((len = in.read(buf)) > 0) {
62                     out.write(buf, 0, len);
63                 }
64                 in.close();
65                 out.close();
66             }
67         } catch (FileNotFoundException fnfex) {
68             fnfex.printStackTrace();
69         } catch (IOException ioex) {
70             ioex.printStackTrace();
71         }
72     }
73
74 }
75
Popular Tags