}
}
private boolean getConnection(XDataSource _dataSource)
{
Resource oResource = new Resource(xMSF, "Database", "dbw");
try
{
int iMsg = 0;
boolean bgetConnection = false;
if (DBConnection != null)
{
xConnectionComponent.dispose();
}
getDataSourceInterfaces();
if (!bPasswordIsRequired)
{
DBConnection = _dataSource.getConnection(PropertyNames.EMPTY_STRING, PropertyNames.EMPTY_STRING);
bgetConnection = true;
}
else
{
XInteractionHandler xInteractionHandler = UnoRuntime.queryInterface( XInteractionHandler.class, xMSF.createInstance("com.sun.star.task.InteractionHandler") );
boolean bExitLoop = true;
do
{
XCompletedConnection xCompleted2 = UnoRuntime.queryInterface( XCompletedConnection.class, _dataSource );
try
{
DBConnection = xCompleted2.connectWithCompletion( xInteractionHandler );
bgetConnection = DBConnection != null;
if (!bgetConnection)
{
bExitLoop = true;
}
}
catch (Exception exception)
{
// Note: WindowAttributes from toolkit/source/awt/vclxtoolkit.cxx
String sMsgNoConnection = oResource.getResText(RID_DB_COMMON + 14);
iMsg = showMessageBox("QueryBox", VclWindowPeerAttribute.RETRY_CANCEL, sMsgNoConnection);
bExitLoop = iMsg == 0;
bgetConnection = false;
}
}
while (!bExitLoop);
}
if (!bgetConnection)
{
String sMsgConnectionImpossible = oResource.getResText(RID_DB_COMMON + 35);
showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMsgConnectionImpossible);
}
else
{
xConnectionComponent = UnoRuntime.queryInterface( XComponent.class, DBConnection );
m_connectionTools = UnoRuntime.queryInterface( XConnectionTools.class, DBConnection );
getDataSourceObjects();
}
return bgetConnection;
}
catch (Exception e)
{
String sMsgConnectionImpossible = oResource.getResText(RID_DB_COMMON + 35);
showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMsgConnectionImpossible);
Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e );
return false;
}
}