package froop.db.jdbc;

import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Apache Derby を Embedded モード(同一プロセス内で起動)で使用する.
 * 参考: http://db.apache.org/derby/
 */
public class DerbyConnectionFactory {
  private final String connectUrl;

  static {
    final String logDir = "logs";
    new File(logDir).mkdir();
    System.setProperty("derby.stream.error.file", logDir + "/derby.log");
  }

  /**
   * @param connectUrl JDBC用のデータベース接続URL
   */
  public DerbyConnectionFactory(String connectUrl) {
    this.connectUrl = connectUrl;
  }

  public Connection getConnection() throws SQLException {
    return DriverManager.getConnection(connectUrl);
  }
}

@@ -21,29 +21,8 @@
 c;%0A%0A
-import java.io.File;%0A
 impo
@@ -111,326 +111,80 @@
 n;%0A%0A
-/**%0A * Apache Derby %E3%82%92 Embedded %E3%83%A2%E3%83%BC%E3%83%89(%E5%90%8C%E4%B8%80%E3%83%97%E3%83%AD%E3%82%BB%E3%82%B9%E5%86%85%E3%81%A7%E8%B5%B7%E5%8B%95)%E3%81%A7%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B.%0A * %E5%8F%82%E8%80%83: http://db.apache.org/derby/%0A */%0Apublic class DerbyConnectionFactory %7B%0A  private final String connectUrl;%0A%0A  static %7B%0A    final String logDir = %22logs%22;%0A    new File(logDir).mkdir();%0A    System.setProperty(%22derby.stream.error.file%22, logDir + %22/derby.log%22);%0A  %7D
+public class DerbyConnectionFactory %7B%0A  private final String connectUrl;
 %0A%0A  

delete derby.log setting