package com.perforce.cvs; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import org.h2.tools.DeleteDbFiles; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class RevisionDB { private Logger logger = LoggerFactory.getLogger(RevisionDB.class); private static Connection connection = null; private final String SQL_CREATE = "CREATE TABLE rev (id INT AUTO_INCREMENT, name varchar(100), value BLOB, primary key (id))"; protected RevisionDB() { String dbPath = "./db/"; String dbFile = "rev"; DeleteDbFiles.execute(dbPath, dbFile, true); String url = "jdbc:h2:" + dbPath + dbFile; try { connection = DriverManager.getConnection(url); PreparedStatement sql = connection.prepareStatement(SQL_CREATE); sql.executeUpdate(); sql.close(); } catch (Exception e) { logger.error(e.getMessage()); } } public static Connection getConnection() throws Exception { if (connection == null) { new RevisionDB(); } return connection; } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 10826 | Paul Allen |
Experiment with H2 Java database. CVS revisions are stored as Blobs with an ID, the RevisionSorter uses the ID and accesses the Blobs to sort change order. Database is located in ${CWD}/db/rev.* |