• R/O
  • SSH
  • HTTPS

clearfybusiness: Commit


Commit MetaInfo

Révision217 (tree)
l'heure2019-06-21 15:19:10
Auteurdaianji

Message de Log

H2db conpact command implemented

Change Summary

Modification

--- org.clearfy/org.clearfy.datawrapper/src/main/java/org/clearfy/datawrapper/Jdbc.java (revision 216)
+++ org.clearfy/org.clearfy.datawrapper/src/main/java/org/clearfy/datawrapper/Jdbc.java (revision 217)
@@ -149,7 +149,9 @@
149149 Statement stmt = connection.createStatement();
150150 rvalue = stmt.execute(cmd);
151151 stmt.close();
152- connection.commit();
152+ if (!connection.isClosed()) {
153+ connection.commit();
154+ }
153155 } catch (SQLException ex) {
154156 Logger.getLogger(Jdbc.class.getName()).log(Level.SEVERE, null, ex);
155157 }
--- org.clearfy/org.clearfy.datawrapper/src/main/java/org/clearfy/datawrapper/h2db/JdbcH2.java (nonexistent)
+++ org.clearfy/org.clearfy.datawrapper/src/main/java/org/clearfy/datawrapper/h2db/JdbcH2.java (revision 217)
@@ -0,0 +1,46 @@
1+/*
2+ * The MIT License
3+ *
4+ * Copyright 2019 Takahiro MURAKAMI.
5+ *
6+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7+ * of this software and associated documentation files (the "Software"), to deal
8+ * in the Software without restriction, including without limitation the rights
9+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+ * copies of the Software, and to permit persons to whom the Software is
11+ * furnished to do so, subject to the following conditions:
12+ *
13+ * The above copyright notice and this permission notice shall be included in
14+ * all copies or substantial portions of the Software.
15+ *
16+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+ * THE SOFTWARE.
23+ */
24+package org.clearfy.datawrapper.h2db;
25+
26+import org.clearfy.datawrapper.Jdbc;
27+
28+/**
29+ * Jdbcの機能にH2dbの特殊な実装を追加
30+ *
31+ * @author Takahiro MURAKAMI
32+ */
33+public class JdbcH2 extends Jdbc {
34+
35+ public JdbcH2(String url) {
36+ super(url);
37+ }
38+
39+ /**
40+ * データベースの圧縮と停止
41+ */
42+ public void shutdownConpact() {
43+ this.execute("SHUTDOWN COMPACT");
44+ }
45+
46+}
--- org.clearfy/org.clearfy.datawrapper/src/main/java/org/clearfy/datawrapper/h2db/MiniServer.java (revision 216)
+++ org.clearfy/org.clearfy.datawrapper/src/main/java/org/clearfy/datawrapper/h2db/MiniServer.java (revision 217)
@@ -128,6 +128,8 @@
128128 jdbcInfo.User.setValue("sa"),
129129 jdbcInfo.Password.setValue("")
130130 );
131+
132+ sSwitch.conpact();
131133
132134 }
133135 }
--- org.clearfy/org.clearfy.datawrapper/src/main/java/org/clearfy/datawrapper/h2db/ServerSwitch.java (revision 216)
+++ org.clearfy/org.clearfy.datawrapper/src/main/java/org/clearfy/datawrapper/h2db/ServerSwitch.java (revision 217)
@@ -72,6 +72,8 @@
7272 private String JdbcDriverName = ServerSwitch.JDBC_DRIVER_MANAGER;
7373
7474 private String url;
75+
76+ private Jdbc cuurentJdbc;
7577
7678 /**
7779 * ドライバの読み込み(規定のドライバを使用する).
@@ -107,7 +109,8 @@
107109
108110 @Override
109111 public Jdbc getJdbc() {
110- Jdbc rvalue = new Jdbc(this.url);
112+ Jdbc rvalue = new JdbcH2(this.url);
113+ this.cuurentJdbc = rvalue;
111114 return rvalue;
112115 }
113116
@@ -169,6 +172,9 @@
169172 return this.dbStatus;
170173 }
171174
175+ /**
176+ * サーバーを停止する。
177+ */
172178 public void off() {
173179 if (this.httpDbServer != null) {
174180 this.httpDbServer.stop();
@@ -180,5 +186,15 @@
180186
181187 this.dbStatus = ServerSwitch.DATABASE_STOPED;
182188 }
189+
190+ /**
191+ * データベースの圧縮
192+ */
193+ public void conpact(){
194+ JdbcH2 jdbc = (JdbcH2) this.cuurentJdbc;
195+ jdbc.shutdownConpact();
196+ this.off();
197+ this.on();
198+ }
183199
184200 }
Afficher sur ancien navigateur de dépôt.