Bug 115988 - "DataSource.ConnectWithCompletion" function not working since 6.x
Summary: "DataSource.ConnectWithCompletion" function not working since 6.x
Status: RESOLVED WORKSFORME
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.0.1.1 release
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-24 10:31 UTC by Alessandro Tassi
Modified: 2018-03-08 03:22 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alessandro Tassi 2018-02-24 10:31:28 UTC
Description:
When trying to perform connection from a basic script, Libreoffice freezes and stops running.
I've isolated the string causing this problem moving a "msgbox" alert through the basic code, that's the following:

Connection = DataSource.ConnectWithCompletion(InteractionHandler)

I attach the whole macro including this command.

It's very usefull to perform connection from a macro script as you may want to open a form containing data on Libreoffice Base startup.

This problem has appeared first when moving from Libreoffice 5 to 6 series.

Thanks a lot.

Alessandro T.

Steps to Reproduce:
'This cod has been working for 4 years since upgrading to Libreoffice 6.x.
'Now the last command blocks everything: Connection = 'DataSource.ConnectWithCompletion(InteractionHandler)

'mysql db name: finanziamenti
'mysql Libreoffice registered name: soviet
'file name: soviet.odb


Function connect
sqlpath="C:\Programmi\MariaDB 10.1\bin\"
NomeDB = "finanziamenti"
Dim DocDBPath as String
DatabaseContext = createUnoService("com.sun.star.sdb.DatabaseContext")
DataSource = DatabaseContext.getByName("soviet")
DocDBPath = DataSource.DatabaseDocument.Location
GlobalScope.BasicLibraries.loadLibrary("Tools")
BaseDir = Tools.Strings.DirectoryNameoutofPath(DocDBPath,"/")
DocDB = DataSource.DatabaseDocument
If Not IsNull(Connection) Then GoTo esci
If Not DataSource.IsPasswordRequired Then
  Connection = DataSource.GetConnection("","")
Else
  InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
  Connection = DataSource.ConnectWithCompletion(InteractionHandler)  '<-------PROBLEM
End If
esci:
End Function

Actual Results:  
I think the same problem occurs with every DB connection, MySql in this case.

Expected Results:
Libreoffice freezes


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
Connect normally with the DB asking name and password, and allowing to see DB data when opening tables and forms.


User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:58.0) Gecko/20100101 Firefox/58.0
Comment 1 Alessandro Tassi 2018-02-24 11:25:50 UTC
Hi, I forgot to specify the type of DB: it's MariaDB 10.1.31-1 on x86_64 Arch Linux laptop, connected by Oracle Mysql Connector Java:
mysql-connector-java-5.1.38-bin.jar .
Upgrading to mysql-connector-java-5.1.45.zip doesn't solve anything, the same using the development version 8.0.9-rc.
Thanks again
Alessandro
Comment 2 Alessandro Tassi 2018-02-24 11:41:31 UTC
I've tryed also using MariaDB java connection (https://mariadb.com/kb/en/library/about-mariadb-connector-j/#getting-a-new-connection), 
changing the connection class from "com.mysql.jdbc.Driver" to "org.mariadb.jdbc.Driver".
The problem i still there.
Comment 3 Xisco Faulí 2018-02-26 10:45:15 UTC Comment hidden (obsolete)
Comment 4 Robert Großkopf 2018-02-26 18:16:32 UTC
Have tried this one with OpenSUSE 42.3 64bit rpm Linux and LO 6.0.0.3, LO 6.0.1.1 and LO 6.0.2.1

I changed the code, because there are many lines without any function for the bug-description:

SUB ConnectDB
oDatasource = ThisComponent.DataSource
If Not oDatasource.IsPasswordRequired Then
Connection = oDatasource.GetConnection("","")
Else
InteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler")
Connection = oDatasource.ConnectWithCompletion(InteractionHandler) 
End If
END SUB

There must be an external database, which needs a username and password. I tried with MariaDB on my system.

I put the code into the *.odb-file, started the code and got the dialog for input password. No problems here with any tested LO-version to connect to the MariaDB this way.
Comment 5 Alessandro Tassi 2018-03-08 00:33:51 UTC
Hi, I've upgraded to Version: 6.0.2.1.0+ Build ID: 6.0.2-1 and the problem seems solved.
Maybe you don't find any matter because you let LO to find the connection by itself and to ask for password?
The problem appeared launching a startup script (Tools > Customize > Events > associating script to "Document Loading Finished" event) or running it from a button.
But now it seems working.
Thanks a lot.
Alessandro
Comment 6 Aron Budea 2018-03-08 03:22:20 UTC
Let's use status WORKSFORME, since the fixing change is unknown.