Dear Frank:

Thanks for the advice.  As regarding the need of

> * How to extract java.sql.Connection from a sdbc.XConnection?
> There's no way to do this - what do you need it for?

This need is vital for business case.  Product managers will not
fund the development unless the code maintenance, etc., is user
friendly.
Pleas notice *maintenance", not just features.  See below for details.

java.sql.Connection           jj_cnct;
com.sun.star.sdbc.XConnection oo_cnct;
oo_cnct = ...;     // require *.odb ZIP decompression
jj_cnct = UnoRuntime.queryInterface( java.sql.Connection.class, oo_cnct
);
jj_cnct = oo_cnct.getJDBCconnection();
// Would the polymorphism notion work as an alternative?
// do_universal_JDBC_SQL_processing( jj_cnct, jdbc_cnct_1, jdbc_rdbms_2,
... );
oo_cnct.close();   // require *.odb ZIP compression

Is there a way to accomplish this conversion?

Ray

 -----

I have had the feeling that this question will surface sometime.  
It has to do with the difference of operating environments between
personal applications and medium size (dept., division, etc.)
businesses.  
Similar problems [1] have occurred with Calc, Base, API as I was trying 
to demonstrate a concept feasibility.

Medium size businesses often have resources to collect and 
maintain multiple groups/types of business intelligence data.  
A typical analysis algorithm needs access to multiple data stores, 
usually in different database engines.  Currently JDBC databases 
greatly outnumber SDBC databases.  It is a nightmare for both 
maintenance and future design revision to duplicate all existing 
and future JDBC SQL algorithm code (java.sql.Connection) 
to another set specifically for sdbc.XConnnection.  
Imagine the cost of double checking both sets of codes, 
potential liability, etc.  

No sensible product manager would ever allow this situation.  
Hence there is a critical need for the conversion between 
Connection and XConnection.

I use Calc as the GUI for Base for business reasons that
might be apparent to people in medium size businesses, but
that might be overlooked by developers of personal applications.
There has been much effort in Base form and Base report.
These features are popular for personal applications.
They are not fit for medium size business need, however.
Imagine the entry of thousands of records through any form.
Imagine telling colleagues to convert spreadsheet files
of thousands of lines of input records into other formats.
Imagine telling colleagues to learn Base GUI for report generation.
They much prefer spreadsheet environment for analysis and report.

Similarly Java or OO Datasource repository is avoided since
it is an obvious target for hacker attacks.

[1] 2.0.4 Base linked tables

http://dba.openoffice.org/servlets/ReadMsg?listName=users&msgNo=4116
http://dba.openoffice.org/servlets/ReadMsg?listName=users&msgNo=4114
(**)
http://dba.openoffice.org/servlets/ReadMsg?listName=users&msgNo=4130
(**)

Similar issues also happened for Calc and API.

 ----

To summarize for other readers:

Subject: get sdbc.Xconnection for existing *.odb files
         that are not registered in data sources and
         without creating additional data source registration.
Language: Java (stand alone Beanshell)

* approach 1: getByName()

// OO Developers Guide 2.0, section 12.2.1 DatabaseContext (near end),
p.832
// quote: Since OpenOffice.org 2.0, getByName() can also be used
// to obtain data sources that are not registered.
import com.sun.star.uno.UnoRuntime;
import java.sql.Connection;
import com.sun.star.sdbc.XConnection;    // not
com.sun.star.connection.XConnection
import com.sun.star.sdbc.XDataSource;    // javax.sql.DataSource
import com.sun.star.container.XNameAccess;
Connection  jj_cnct;
XConnection oo_cnct;
XDataSource dsrc;
XNameAccess lsts;  // data source list
Object      prxy;
lsts = ...  // get the data source list from database context
prxy = lsts.getByName( "file:///d:/test 01.odb" );
dsrc = UnoRuntime.queryInterface( XDataSource.class, prxy );
oo_cnct = dsrc.getConnection( "sa", "" );

* approach 2: loadComponentFromURL()

XDatabaseDocumentUI  base_uiui;  // unpublished API in 2.0
XController     base_cntl;
XModel          base_modl;
XComponent      base_cmpt;
XConnection     oo_cnct;
Boolean         okok;
Base_cmpt = XComponentLoader.loadComponentFromURL( ... );
base_modl = UnoRuntime.queryInterface( XModel.class, base_cmpt );
base_cntl = base_modl.getCurrentController();
base_uiui = UnoRuntime.queryInterface( XDatabaseDocumentUI.class,
base_cntl );
okok      = base_uiui.connect();
oo_cnct   = base_uiui.ActiveConnection;

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to