本文整理汇总了Java中org.bridgedb.rdb.construct.DBConnector类的典型用法代码示例。如果您正苦于以下问题:Java DBConnector类的具体用法?Java DBConnector怎么用?Java DBConnector使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DBConnector类属于org.bridgedb.rdb.construct包,在下文中一共展示了DBConnector类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: finalize
import org.bridgedb.rdb.construct.DBConnector; //导入依赖的package包/类
/**
* Run this after insterting all sample / expression data
* once, to defragment the db and create indices.
* This method closes the current database connection in order
* for the {@link DBConnector} to clean up.
*/
public void finalize() throws IDMapperException
{
try
{
con.commit();
}
catch (SQLException e)
{
throw new IDMapperException (e);
}
dbConnector.compact(con);
createGexIndices();
dbConnector.closeConnection(con, DBConnector.PROP_FINALIZE);
//The dbConnector may change the database file after cleaning up,
//for example, the derby connector first creates the database as directory
//and then adds the database to a zip file and removes the directory.
//The database name needs to be changed to the zip file in this case.
String newDb = dbConnector.finalizeNewDatabase(dbName);
setDbName(newDb);
}
示例2: createNewGex
import org.bridgedb.rdb.construct.DBConnector; //导入依赖的package包/类
/**
* Create a new database with the given name. This includes creating tables.
* @param dbName The name of the database to create
* @return A connection to the newly created database
* @throws Exception
* @throws Exception
*/
public final void createNewGex(String dbName) throws DataException
{
try
{
con = dbConnector.createConnection(dbName, DBConnector.PROP_RECREATE);
this.dbName = dbName;
createGexTables();
}
catch (IDMapperException ex)
{
throw new DataException(ex);
}
}
示例3: actionPerformed
import org.bridgedb.rdb.construct.DBConnector; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
try
{
/**
* Get the preferred database connector to connect to Gex databases,
* and try to cast it to swingDbConnector.
* throws an exception if that fails
*/
DBConnectorSwing dbcon;
DBConnector dbc = desktop.getGexManager().getDBConnector();
if(dbc instanceof DBConnectorSwing)
{
dbcon = (DBConnectorSwing)dbc;
}
else
{
//TODO: better handling of error
throw new IllegalArgumentException("Not a Swing database connector");
}
String dbName = dbcon.openChooseDbDialog(desktop.getFrame());
if(dbName == null) return;
desktop.getGexManager().setCurrentGex(dbName, false);
desktop.loadGexCache();
}
catch(Exception ex)
{
String msg = "Failed to open expression dataset; " + ex.getMessage();
JOptionPane.showMessageDialog(desktop.getFrame(),
"Error: " + msg + "\n\n" + "See the error log for details.",
"Error",
JOptionPane.ERROR_MESSAGE);
Logger.log.error(msg, ex);
}
}
示例4: gexHelper
import org.bridgedb.rdb.construct.DBConnector; //导入依赖的package包/类
public void gexHelper(DBConnector con, String filename) throws IDMapperException, SQLException, DataException
{
String dbFileName = System.getProperty("java.io.tmpdir") + File.separator + filename;
// TODO: check if filename gets .pgex or .pgdb?
SimpleGex sgex = new SimpleGex (dbFileName, true, con);
sgex.prepare();
sgex.addSample(55, "mysample", 99);
sgex.addExpr(new Xref ("abc_at", BioDataSource.AFFY), "55", "3.141", 77);
// TODO: this is messy. call finalize on writeable db, not close...
sgex.finalize();
// read data back
sgex = new SimpleGex (dbFileName, false, con);
ISample s = sgex.getSample(55);
assertEquals (s.getName(), "mysample");
assertEquals (s.getDataType(), 99);
//TODO: test data value as well.
sgex.close();
assertTrue (new File(dbFileName + ".pgex").exists());
}
示例5: actionPerformed
import org.bridgedb.rdb.construct.DBConnector; //导入依赖的package包/类
public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand();
if(ACTION_GDB.equals(action)) {
standaloneEngine.selectGdb("Gene");
txtGdb.setText(
PreferenceManager.getCurrent().get(GlobalPreference.DB_CONNECTSTRING_GDB)
);
} else if(ACTION_INPUT.equals(action)) {
File defaultdir = PreferenceManager.getCurrent().getFile(GlobalPreference.DIR_LAST_USED_EXPRESSION_IMPORT);
JFileChooser jfc = new JFileChooser();
jfc.setCurrentDirectory(defaultdir);
jfc.addChoosableFileFilter(new SimpleFileFilter("Data files", "*.txt|*.csv|*.tab", true));
int result = jfc.showDialog(null, "Select data file");
if (result == JFileChooser.APPROVE_OPTION)
{
File f = jfc.getSelectedFile();
defaultdir = jfc.getCurrentDirectory();
PreferenceManager.getCurrent().setFile(GlobalPreference.DIR_LAST_USED_EXPRESSION_IMPORT, defaultdir);
txtInput.setText("" + f);
updateTxtFile ();
}
} else if(ACTION_OUTPUT.equals(action)) {
try {
DBConnector dbConn = standaloneEngine.getGexManager().getDBConnector();
String output = ((DBConnectorSwing)dbConn).openNewDbDialog(
getPanelComponent(), importInformation.getGexName()
);
if(output != null) {
txtOutput.setText(output);
}
} catch(Exception ex) {
JOptionPane.showMessageDialog(
getPanelComponent(), "The database connector is not supported"
);
Logger.log.error("No gex database connector", ex);
}
}
}