Re: How to establish an activeConnetion on launching Openoffice.org BASE with embedded HSQLDB
Fernand Vanrie <[email protected]> Fri, 04 Mar 2011 09:41:49 +0100
| Newsgroups | gmane.comp.openoffice.dba.user |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------010303070703070001080608
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Rik,
Me again :-)
found a complete sub who works on HSQLDB but also not run from in the
BaseDoc itself
Sub SaveToDB (path as string)
oSrcFilePath = ConvertToUrl(path)
oFileAccessService = createUnoService("com.sun.star.ucb.SimpleFileAccess")
oTextInputStream = createUnoService("com.sun.star.io.TextInputStream")
oTextInputStream.setInputStream(oFileAccessService.openFileRead(oSrcFilePath))
'xray oTextInputStream
ss = oTextInputStream.readstring(array(),false)
oDatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
oDataSource = oDatabaseContext.getByName("ODF_test_PI")
oConnection = oDataSource.GetConnection("","")
' prepare the Statement
sSQL = "INSERT INTO TEST(HTML) VALUES(?)"
Statement = Oconnection.PrepareStatement(sSQL)
' insert ss for ( ? ) placeholder 1
Statement.setString(1,ss)
' write to Database ( Use iAccess to check Success if you want)
iAccess = Statement.executeUpdate()
print iAccess
if iAccess = 1 then
' oSimpleFileAccess.kill( path )
endif
sStatement = oconnection.createstatement
sSQL = "Select * from TEST where AUTO = 119"
sStatement.execute(sSQL)
resultset = sstatement.getresultset
resultset.next
' xray resultset
sHTML = resultset.getString(3)
InsertHTMLContent(sHTML)
End Sub
> Rik,
>
> normaly for a OO-Dbase connectyed to MYSQL i use
>
> oDB = CreateUnoService("com.sun.star.sdb.DatabaseContext")
> if not oDB.hasbyname("OODbaseName")then
> oDB.registerDatabaseLocation("mOODbaseName",converttoURL("Path to
> OODbasename.odb")
> endif
> oConn = oDB.GetByName("OODbaseName").GetConnection("User","Password")
>
> Hope it helps
> Fernand
>> Hello together,
>> I'm new here, and i have a serious problem with my Base DB with
>> embedded HSQLDB.
>> I'm not shure, if the problem exists 'cause of my Hard- and Software
>> combination or if it's a serious bug in Base.
>> Using OOo 3.3-Base, Windows 7 and tryed out JRE 1.6.0_20/22/24 the
>> problem exists with all of them:
>> When launching Openoffice.org BASE with embedded HSQLDB and directly
>> *open a form* or dialog *via basic macro*,
>> *all inserted and changed datas are lost on closing the database
>> document*.
>> That means, opening a Form in code does work, and I can see the datas
>> of the HSQLDB in the form.
>> They also can be changed. Reopening the form via code shows the
>> changed datas, i think they are written to cached tables, but not to
>> the hard disk.
>> By closing the database-document, all added or changed datas are lost.
>>
>> With xray I found out, that there is no "activeConnection" into
>> HSQLDB established by opening forms or dialogs on this way.
>> When i change once into "Table view", then
>> "thisComponent.currentcontroller.activeConnection" can be seen with
>> Xray, otherwise it's a "Null Object".
>> In this case, all added and changed datas will be written to the
>> embedded HSQLDB, nothing lost.
>> Does anybody know, how to establish the "activeConnection" via Basic?
>> Rik Hustede
>
--
-----------------------------------------------------------------
To unsubscribe send email to [email protected]
For additional commands send email to [email protected]
with Subject: help
--------------010303070703070001080608
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Rik,<br>
<br>
Me again :-)<br>
<br>
found a complete sub who works on <font size="2" color="#080000"
face="Arial">HSQLDB but also not run from in the BaseDoc itself<br>
<br>
</font><font color="#080000"><font size="2"><font face="Arial">Sub
SaveToDB (path as string) <br>
oSrcFilePath = ConvertToUrl(path)<br>
oFileAccessService =
createUnoService("com.sun.star.ucb.SimpleFileAccess") <br>
oTextInputStream =
createUnoService("com.sun.star.io.TextInputStream")<br>
oTextInputStream.setInputStream(oFileAccessService.openFileRead(oSrcFilePath))
<br>
'xray oTextInputStream<br>
ss = oTextInputStream.readstring(array(),false)<br>
<br>
oDatabaseContext =
createUnoService("com.sun.star.sdb.DatabaseContext") <br>
oDataSource = oDatabaseContext.getByName("ODF_test_PI") <br>
oConnection = oDataSource.GetConnection("","") <br>
<br>
' prepare the Statement <br>
sSQL = "INSERT INTO TEST(HTML) VALUES(?)" <br>
Statement = Oconnection.PrepareStatement(sSQL)<br>
' insert ss for ( ? ) placeholder 1 <br>
<br>
Statement.setString(1,ss)<br>
<br>
' write to Database ( Use iAccess to check Success if you
want) <br>
iAccess = Statement.executeUpdate()<br>
print iAccess<br>
if iAccess = 1 then<br>
' oSimpleFileAccess.kill( path )<br>
endif<br>
<br>
sStatement = oconnection.createstatement <br>
sSQL = "Select * from TEST where AUTO = 119"<br>
sStatement.execute(sSQL) <br>
resultset = sstatement.getresultset<br>
resultset.next<br>
' xray resultset<br>
sHTML = resultset.getString(3)<br>
<br>
InsertHTMLContent(sHTML)<br>
<br>
End Sub </font></font></font><br>
<blockquote cite="mid:[email protected]" type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
Rik,<br>
<br>
normaly for a OO-Dbase connectyed to MYSQL i use<br>
<br>
oDB = CreateUnoService("com.sun.star.sdb.DatabaseContext")<br>
if not oDB.hasbyname("OODbaseName")then<br>
oDB.registerDatabaseLocation("mOODbaseName",converttoURL("Path
to OODbasename.odb")<br>
endif<br>
oConn =
oDB.GetByName("OODbaseName").GetConnection("User","Password")<br>
<br>
Hope it helps<br>
Fernand<br>
<blockquote cite="mid:5A2ABB1235B247419622F064D1640197@HustedePC"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<meta name="GENERATOR" content="MSHTML 8.00.7600.16722">
<div><font size="2" color="#080000" face="Arial">Hello together,</font></div>
<div> </div>
<div><font size="2" color="#080000" face="Arial">I'm new here,
and i have a serious problem with my Base DB with embedded
HSQLDB.</font></div>
<div><font size="2" color="#080000" face="Arial">I'm not shure,
if the problem exists 'cause of my Hard- and Software
combination or if it's a serious bug in Base.</font></div>
<div><font size="2" color="#080000" face="Arial">Using <font
size="2" color="#080000" face="Arial">OOo 3.3-Base,
Windows 7 and tryed out JRE 1.6.0_20/22/24 the
problem exists with all of them:</font></font></div>
<div><font size="2" color="#080000" face="Arial"> </font></div>
<div>
<div><font size="2" color="#080000" face="Arial"><font
size="2" color="#080000" face="Arial">When launching
Openoffice.org BASE with embedded HSQLDB and directly <strong>open
a form</strong> or dialog <strong>via basic macro</strong>,
</font></font></div>
<div><font size="2" color="#080000" face="Arial"><font
size="2" color="#080000" face="Arial"><strong>all
inserted and changed datas are lost on closing the
database document</strong>.</font></font></div>
</div>
<div><font size="2" color="#080000" face="Arial"> </font></div>
<div><font size="2" color="#080000" face="Arial"><font size="2"
color="#080000" face="Arial">That means, opening a Form in
code does work, and I can see the datas of the HSQLDB in
the form. </font></font>
<div><font size="2" color="#080000" face="Arial"><font
size="2" color="#080000" face="Arial"><font size="2"
color="#080000" face="Arial">They also can be changed.
Reopening the form via code shows the changed datas, i
think they are written to cached tables, but not to
the hard disk.</font></font></font></div>
<div><font size="2" color="#080000" face="Arial"><font
size="2" color="#080000" face="Arial"><font size="2"
color="#080000" face="Arial">By closing the
database-document, all added or changed datas are
lost.</font></font></font></div>
</div>
<div><font size="2" color="#080000" face="Arial"><font size="2"
color="#080000" face="Arial"><br>
With xray I found out, that there is no "activeConnection"
into HSQLDB established by opening forms or dialogs on
this way.</font></font></div>
<div><font size="2" color="#080000" face="Arial"><font size="2"
color="#080000" face="Arial"> </font></font></div>
<div>
<div><font size="2" color="#080000" face="Arial"><font
size="2" color="#080000" face="Arial"><font size="2"
color="#080000" face="Arial">When i change once into
"Table view", t</font><font size="2" color="#080000"
face="Arial">hen
"thisComponent.currentcontroller.activeConnection" can
be seen with Xray, otherwise it's a "Null Object".</font></font></font></div>
<div><font size="2" color="#080000" face="Arial"><font
size="2" color="#080000" face="Arial"><font size="2"
color="#080000" face="Arial">In this case, all added
and changed datas will be written to the embedded
HSQLDB, nothing lost.</font></font></font></div>
<div><font size="2" color="#080000" face="Arial"><font
size="2" color="#080000" face="Arial"> </font></font></div>
</div>
<font size="2" color="#080000" face="Arial"> </font>
<div>
<div><font size="2" color="#080000" face="Arial"> </font></div>
</div>
<div><font size="2" color="#080000" face="Arial"><font size="2"
color="#080000" face="Arial">Does anybody know, how to
establish the "activeConnection" via Basic?</font></font></div>
<div><font size="2" color="#080000" face="Arial"> </font></div>
<div><font size="2" color="#080000" face="Arial"> </font></div>
<div><font size="2" color="#080000" face="Arial">Rik Hustede</font></div>
<div><font size="2" color="#080000" face="Arial"> </font></div>
<div><font size="2" color="#080000" face="Arial"> </font></div>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>
--------------010303070703070001080608--