use of org.hsqldb_voltpatches.Database in project voltdb by VoltDB.
the class DatabaseInformation method newDatabaseInformation.
/**
* Factory method returns the fullest system table producer
* implementation available. This instantiates implementations beginning
* with the most complete, finally choosing an empty table producer
* implemenation (this class) if no better instance can be constructed.
* @param db The Database object for which to produce system tables
* @return the fullest system table producer
* implementation available
*/
public static final DatabaseInformation newDatabaseInformation(Database db) {
Class c = null;
try {
c = Class.forName("org.hsqldb_voltpatches.dbinfo.DatabaseInformationFull");
} catch (Exception e) {
try {
c = Class.forName("org.hsqldb_voltpatches.dbinfo.DatabaseInformationMain");
} catch (Exception e2) {
}
}
try {
Class[] ctorParmTypes = new Class[] { Database.class };
Object[] ctorParms = new Object[] { db };
Constructor ctor = c.getDeclaredConstructor(ctorParmTypes);
return (DatabaseInformation) ctor.newInstance(ctorParms);
} catch (Exception e) {
e.printStackTrace();
}
return new DatabaseInformation(db);
}
use of org.hsqldb_voltpatches.Database in project voltdb by VoltDB.
the class ScaledRAFile method newScaledRAFile.
/**
* seekPosition is the position in seek() calls or after reading or writing
* realPosition is the file position
*/
static Storage newScaledRAFile(Database database, String name, boolean readonly, int type, String classname, String key) throws FileNotFoundException, IOException {
if (classname != null) {
try {
Class zclass = Class.forName(classname);
Constructor constructor = zclass.getConstructor(new Class[] { String.class, Boolean.class, Object.class });
return (Storage) constructor.newInstance(new Object[] { name, new Boolean(readonly), key });
} catch (ClassNotFoundException e) {
throw new IOException();
} catch (NoSuchMethodException e) {
throw new IOException();
} catch (InstantiationException e) {
throw new IOException();
} catch (IllegalAccessException e) {
throw new IOException();
} catch (java.lang.reflect.InvocationTargetException e) {
throw new IOException();
}
}
if (type == DATA_FILE_JAR) {
return new ScaledRAFileInJar(name);
} else if (type == DATA_FILE_RAF) {
return new ScaledRAFile(database, name, readonly);
} else {
RandomAccessFile file = new RandomAccessFile(name, readonly ? "r" : "rw");
if (file.length() > MAX_NIO_LENGTH) {
return new ScaledRAFile(database, name, file, readonly);
} else {
file.close();
}
try {
Class.forName("java.nio.MappedByteBuffer");
Class c = Class.forName("org.hsqldb_voltpatches.persist.ScaledRAFileHybrid");
Constructor constructor = c.getConstructor(new Class[] { Database.class, String.class, boolean.class });
return (ScaledRAInterface) constructor.newInstance(new Object[] { database, name, new Boolean(readonly) });
} catch (Exception e) {
return new ScaledRAFile(database, name, readonly);
}
}
}
Aggregations