I’ve just installed Libre Office 5.2.3.3, and I am unable to run a macro. It was running without error yesterday, but won’t run today. The problem appears to be when the macro tries to process the standard function GetConnection(). When I attempt to run the macro, I get the error:
BASIC runtime error.
An exception occurred
Type: com.sun.star.sdbc.SQLException
Message: General error: org.hsqldb.lib.FileSystemRuntimeException: java.io.IOException: .
This message is not very helpful. It throws the error when it gets to the line containing getConnection. I’d like to find out what the problem is so I can fix it.
Sub UpdateSQL
rem Run an SQL command on a table in LibreOffice Base
Context = CreateUnoService("com.sun.star.sdb.DatabaseContext")
rem identify absolute address of database
DatabaseAddress = "file:///C:/Douments and Settings/Administrator/Desktop/punchclock_v0.0.1.odb"
rem create database object
Db = Context.getByName(DatabaseAddress)
rem connect to the database
Conn = Db.getConnection("","")
rem create statement object
Stmt = Conn.createStatement()
rem get date value
dim valDATE as date
valDATE=now()
rem formt as yyyy-mm-dd hh:mm:ss.fffffffff
dim strDATE as string
strDATE=format(valDATE,"yyyy-mm-dd hh:mm:ss")
rem compose SQL statement
rem insert date values into table
strSQL = "INSERT INTO ""tblClock"" (""PunchIn"",""PunchOut"") VALUES ('" + strDATE + "','2016-03-28');"
rem execute SQL statement
Stmt.executeUpdate(strSQL)
rem close the databae connection
Conn.close()
rem notify the user
msgbox("table updated")
End Sub
For what its worth, when I first started building the macro, I was getting the same error. But somehow I resolved it. The best I can recall is that I was attempting to troubleshoot by stepping though the macro. With the LibreOffice BASIC editor open, the save button changed to a save button with a star superimposed. Once I clicked the save icon, that seemed to have fixed it (for the time being).
Now the problem is back.