Talk:Suggestions
From PlainOldWebserver
Any plans for a servlet container/java web server? How hard would this be to implement? I'd be interested in contributing -- email me at nathanael.jones@gmail.com. Thanks!
I've noticed problem with pow_DB.drop_database on Windows (I'm not sure if it appears on *nix or MAC)
Function wasn't removing *.sqlite files and returned error message in log files:
Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsILocalFile.remove]
It was result of not closing database file prior to attempt of removing file.
My solution:
function pow_DB(db_name) {
this.dbname = "";
/* Creates database if it does not exist. Holds connection open. */
this.open = function( db_name ) {
try {
this.dbname = pow_bc_get_data_directory() +"/" + db_name+".sqlite";
var new_file = pow_file_get_handle(this.dbname);
var storageService = Components.classes["@mozilla.org/storage/service;1"]
.getService(Components.interfaces.mozIStorageService);
var mDBConn = storageService.openDatabase(new_file);
return mDBConn;
} catch (e) {
log_error(e);
this.dbname = "";
}
return null;
};
/* Closes opened database. */
this.close = function () {
if (this.conn) {
this.conn.close();
this.conn = null;
this.dbname = "";
}
return this.conn;
}
/* Deletes database file. */
this.drop_database = function() {
try {
var d = this.dbname;
if (!this.close()) {
pow_delete_file(d);
return true;
}
} catch (e) {
log_error(e);
}
return false;
};
/* Connection object. Should be closed later. */
this.conn = this.open(db_name);
if (!this.conn) {
throw new Error("DB not open");
}
this.exec = function(statement) {
if (!this.conn)
throw new Error("Database not open");
. . .