Make HSQLDB Compatibility with DB2 - db2

HSQL-2.3.2 is using as in-memory to test the application which is integrated DB2.
So I am setting sql.syntax_db2=true in url as below in order to provide DB2 compatibility
jdbc:hsqldb:file:{path};shutdown=true;sql.syntax_db2=true
when above url using "SET DATABASE SQL SYNTAX DB2 FALSE" statement created in generated script file,but when i am passing db2,ora syntax true as below
jdbc:hsqldb:file:{path};shutdown=true;sql.syntax_db2=true;sql.syntax_ora=true
then both statements SET DATABASE SQL SYNTAX DB2 TRUE and SET DATABASE SQL SYNTAX ORA TRUE are created and db2 syntax is not executing and below exception firing
nested exception is java.sql.SQLSyntaxErrorException: unexpected token: IGNORE
So please share where needs to make change in order to make DB2 compatibility?
Thanks,
Durgesh

Related

SQLCODE=-104, SQLSTATE=42601, SQLERRMC=table;reorg ;JOIN <joined_table>

when running this query on db2 on DBeaver :
reorg table departments
i got this error (just on external channel):
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=table;reorg ;JOIN <joined_table>, DRIVER=4.19.49
what does this query mean?
how can I fix the error?
appricicate any help.
Try call sysproc.admin_cmd('reorg table db2inst1.departments')
as you are using DBeaver which is a jdbc application.
If you do not qualify the table name (for example, with db2inst1) then Db2 will assume that the qualifier (schema name) is the same as the userid name you used when connecting to the database.
DBeaver runs SQL statements, but it cannot directly run commands of Db2 - instead, any jdbc app can run Db2-commands indirectly via a stored-procedure that you CALL. The CALL is an SQL statement.
The reorg table is a command, it is not an SQL statement, so it needs to be run via the admin_cmd stored-procedure, or it can be run from the operating system command line (or db2 clp) after connecting.
So if you have db2cmd.exe on MS-Windows, or bash on linux/unix, you can connect to the database, and run commands via the db2 command.

dBeaver (CE): DB2 LUW Connection with SQL ERROR 42704. Table Schema won't open but able to write SQL queries

After about a year and half, I am finally able to connect to the DB2 database we have through dBeaver. The connection is successful as a LUW (Our db2 is z/os). I was able to get the drivers required after installing IBM Data Studio.
Once I am connected, I go down the schema, get to Tables, and on clicking that, I get the below error.
SQL Error [42704]: SYSCAT.SCHEMATA IS AN UNDEFINED NAME. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.69.56
SYSCAT.SCHEMATA IS AN UNDEFINED NAME. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.69.56
THE DESCRIBE STATEMENT DOES NOT SPECIFY A PREPARED STATEMENT. SQLCODE=-516, SQLSTATE=26501, DRIVER=3.69.56
THE CURSOR SQL_CURLH200C1 IS NOT IN A PREPARED STATE. SQLCODE=-514, SQLSTATE=26501, DRIVER=3.69.56
SQL Error [42704]: SYSCAT.SCHEMATA IS AN UNDEFINED NAME. SQLCODE=-204, SQLSTATE=42704, DRIVER=3.69.56
However, if ignore the error and go to New SQL query and write a simple
Select * from schema.table
it works fine and get the results I want.
Considering the time i have spent to get till here, this is sufficient, but to deploy as a solution in my department, I need to be able to look at a Table List (schema).
Any help would be awesome.
EDIT1: What the issue is here, is that there is no SCHEMA with the name SYSCAT and no table named SCHEMATA.
The z/OS Db2 catalog has different names than the ones used on Db2 on distributed (Linux Unix Windows aka LUW). Here is a list of objects on Db2 z/OS that you can review.
It looks like you are using dBeaver to navigate through a UI the objects on Db2 for z/OS. You will need to ensure you have a db2 jcc driver that is for z/OS Db2. It looks like you may be using one from LUW as the SYSCAT.SCHEMATA is an LUW object, not a z/OS object.
Your other query works because you are specifying a known table name. Other queries should be fine. The issue is the interface in dbeaver is looking at Db2 system objects for LUW and not z/OS. This will continue until you are able to resolve the driver issue.
The IBM Data Server Drivers also require server sided set-up. Please see this information https://www.ibm.com/support/knowledgecenter/SSEPEK_12.0.0/java/src/tpc/imjcc_jccenablespsandtables.html
In DBeaver, when you create a connection choose the "DB2 z/OS driver" option under the Db2 drop down, when connecting to DB2 for z/OS
BTW DBeaver can shell share with Data Studio, so you can (if you wish) use both products in one install. No guarantees that they share happily in all cases, but it appears to work reasonably well.

Tomcat 8 Db2 Error: com.ibm.db2.jcc.b.eo: DB2 SQL Error: SQLCODE=-551, SQLSTATE=42501, SQLERRMC=M25044

I have been trying to resolve this error which was working for so long
out of nowhere we have started facing this issue.
My application, which is a plain Java web application (Jsp/Servlets and couple of utilities and control classes) running on Tomcat 8
One of the functionality is, the user keys in an id which is a key for a DB query to fire up the Database and get the results
In doing so I get this below error, which is more or less a symptom of user not having the privilege to execute the query on the
Db2 Database table.
When I am trying out the same query from any kind of Db2 Client tools or SQL prompt, I don't get this error at all:
" com.ibm.db2.jcc.b.eo: DB2 SQL Error: SQLCODE=-551, SQLSTATE=42501, SQLERRMC=M25044"
SQLCODE -551 means that the User executing the Query does not have the right Privilege. So find out which User is running the Query and grant the Privilege to that User. May be from other SQL Clients you use a different User.

Install4j - Is it possible to run TSQL queries?

When working with Server-Sql, sometimes it needs to use Transact-SQL queries. Is it possible to execute it through Install4j?
EDIT
I'm using the Server SQL JDBC driver: - com.microsoft.sqlserver.jdbc.SQLServerDriver.
When I'm trying to execute the following script in the SSMS it works without any problem:
USE [${installer:DbName}]
GO
CREATE USER [Guest] FOR LOGIN [Guest]
GO
USE [${installer:acDbName}]
GO
ALTER ROLE [db_owner] ADD MEMBER [Guest]
GO
, but when executing it with the "Execute SQL script" I get the following error: com.install4j.runtime.beans.actions.jdbc.ExecuteSqlScriptAction [ID 8123]: Error executing script line "U", error message: "Could not find stored procedure 'U'."
When enabling the statement delimeter with ; I'm getting the next error:
"Incorrect syntax near 'GO'."
It depends on whether the JDBC driver that you are using can handle TSQL or not, install4j does not have support for specific databases.

LibreOffice Base Execute Stored Procedure/Function

I'm busy setting up a odb file with LibreOffice Base to be used with LibreOffice Calc. The odb file is working fine I can create and save regular queries but it is giving an error when I try to execute a Stored Procedure/Function. When using pgAdmin I can execute the call just fine
select * from funcProduction(current_date, current_date);
This works and returns the data expected but when I try in LibreCalc Base using Queries > Create Query in SQL View, executing the exact same call to the Stored Procedure/Function it fails with an error
Syntax error in SQL statement
I'm not sure why there's an error or even where to find what the error is
Set the query to Run SQL command directly. This is best for any engine except HSQLDB 1.8.
Related:
https://ask.libreoffice.org/en/question/133467/base-andor-syntax-w-mysql/?answer=133476#post-id-133476
sql dialect in OpenOffice Base
https://superuser.com/a/899223/541756