Cancel long running queries in HSQLDB / JDBC - sql

We have got a large number of long running SQL queries and would like to be able to cancel the execution. So far, I am using an ExecutorCompletionService to run the queries, which works well for cancelling queries which are not yet run.
My problem is: I would like to hard-cancel the currently running queries too. The method java.sql.Statement.cancel() does not seem to work with HSQLDB. From the java doc: "Cancels this Statement object if both the DBMS and driver support aborting an SQL statement." I guess that HSQLDB does not support cancellation.
Does anyone have any idea how to cancel the statement anyways (in a possibly ugly, but still acceptable way)?

See https://sourceforge.net/p/hsqldb/bugs/1436/ for a working solution.
The short variant:
Use the newest SVN Version of HSQLDB or the 2.3.4 Final for the Server.
If the current query that you want to cancel is using a hsqldb connection, create a new connection with admin rights to the same server.
Use
select * from information_schema.system_sessions
to find the session with the statement you are looking for.
Use
ALTER SESSION <SESSIONNUMBER> RELEASE
to cancel the Statement.
Close the Connection.

For me the working sql command was ALTER SESSION <SESSIONNUMBER> END STATEMENT

Related

Sybase ASE system stored procedures are returning nothing

System stored procedures such as sp_displayroles, sp_helpdevice, amongst many others, are returning nothing. When I run sp_helpdevice;, all I get as a return value is a string 'sp_helpdevice'. Any idea how to check what's wrong?
I would like to see what devices are present so I may run ALTER DATABASE <database> LOG ON <device>= '20m'; to allow for larger transaction logs.
Edit:
I have the proper permission with sa_role.
I have resolved the problem. I was running the queries via Oracle SQL Developer. It was giving problems probably due to the SQL developer's Sybase DB driver not being very compatible with ASE v16. After using the native ISQL, I can see the results formatted properly.

Oracle DB function log file

I executed a script in unix that called a function in oracle db. I didn't gave the logfile information for the unix script. Usually, when I run a script to call a db function, I give logfile for script and monitor the unix log file and know that if the function is still running or is done. Also, the logfile has information whether the function executed successfully or not.
I have following concerns, based on above situation:
Can I monitor if the function is still running or not using oracle sql developer?
Can I know if the funtion executed successfully in Oracle DB or not? If oracle saves a log of function execution and I could access that then it would be great.
Thank You
Yes, you can monitor if the function is still running by checking the session's status in v$session. See this answer for information on how: How to list active / open connections in Oracle?
As for what the execution result was... probably not.
The PL/SQL you executed won't directly appear in dba_audit_trail, but any queries it ran as part of execution might. The audit trail will show if the queries were successful or not, but it won't show the query results or the final result of the function execution.

Modify statement prior execution

I use an application connected with an sql database. I found using the profiler that the application runs an update query with a syntax error. I don't have access to the application's source code. The result is that the record is not updated. Is there a way to modify the query every time it is executed with something like trigger? I can't use INSTEAD OF because there ism't any record updated or inserted.
This answer
https://stackoverflow.com/a/3319031/1359088
suggests a way to log to a text file all the errors. You could write a little utility and schedule it to run every hour or whatever, which could read through this log, find the erroneous sql statements, fix them, then run them itself.

Run SQL script on multiple DB connections at same time in Oracle SQL Developer

I have 4 different database connections in Oracle SQL Developer. All of them have the exact same set of packages and procedures. Every time I change something in my scripts I have to run it on all of the connections one-by-one. Is there no way to run it on all the connections at the same time?
I'm afraid that you can only execute SQL developer queries on different connections using the GUI.
You should, however, be able to acheive what you want using SQLPlus instead.
You can use "create database link" function:
CREATE DATABASE LINK linkDB_1
CONNECT TO xxxx IDENTIFIED BY xxxx
USING 'xxxxx';
SELECT *
FROM tablename#linkDB_1;
DROP DATABASE LINK linkdb_1;
I tested on my SQL Navigator, and it works.

How do I access an MS Access database from Oracle?

Configured access from Oracle to MS Access.
Oracle XE 11.2.0.2.
Microsoft Access 2010
There are two INSERTS (insert into table that is residing in MS ACCESS db) operations. One of them is using pl\sql variables, another one is not.
First insert:
insert into SomeTable#MSADB("ID", "Name")
values(l_ID, l_Name);
Second one:
insert into SomeTable#MSADB("ID", "Name")
values(123, 'SomeName');
In a case of second insert, all is fine. But first one gives an error "HYC00 NativeError=106 optional feature not implemented". I just can't understand why this is happening and how to solve this problem.
Bind variables(execute immediate) didn't solve this problem. DBMS_HS_PASSTHROUGH.BIND_VARIABLE didn't solve this problem either.
Only solution I see is embedding those variables into a string and then execute it.
Are there another solutions to force the first insert to work?
Thank you.
There was a known issue in the Oracle 11g client with the ODBC driver connecting to excel workbooks and it was giving the same error. Oracle released Patch 7009291 to address that issue so you might take a look at that patch to see if it will address the access issue as well.
You can also enable DG4ODBC tracing to see what is going on and identify if this is a similar issue to the excel one. Tracing is enabled by setting in your init.ora file HS_FDS_TRACE_LEBVEL=255 The trace file is then found in your \hs\trace