Set HSQLDB data type in hibernate configuration files? - hsqldb

I am trying to create an in-memory DB using HSQLDB 2.2.5. We are also using Hibernate. The problem is that our Domain Objects are annotated for Oracle. We generate the HBM files from the POJOs. Hence I am getting "type not found or user lack privileges: NUMBER" errors when I attempt to run against HSQLDB. HSQL 2.2.5 doesn't support NUMBER, only NUMERIC.
Is there any way in the hibernate configuration file or hibernate.properties to tell HSQL to treat NUMBER as NUMERIC?

Well, this version of HSQLDB supports the Oracle syntax compatibility and accepts MUMBER in this mode, plust many other Oracle-specific features. See the Guide for details.
http://hsqldb.org/doc/2.0/guide/deployment-chapt.html#N14266

Related

Hibernates' slow sql queries in Websphere Liberty

I'm deploying an EAR to Websphere Liberty 21.0.0.6 with persistence provider Hibernate 5.4 (my problem persists in version 5.5). Database is Oracle 12c.
I activated Hibernate's feature of logging slow sql queries via persistence.xml (https://docs.jboss.org/hibernate/orm/5.5/javadocs/org/hibernate/cfg/AvailableSettings.html#LOG_SLOW_QUERY)
The setting is working, but unfortunately, Liberty has a prepared statement wrapper that has no sensible toString() method. So the output in my logs is
org.hibernate.SQL_SLOW: SlowQuery: 3299 milliseconds. SQL: 'com.ibm.ws.rsadapter.jdbc.v42.WsJdbc42PreparedStatement#229da89'
org.hibernate.SQL_SLOW: SlowQuery: 2230 milliseconds. SQL: 'com.ibm.ws.rsadapter.jdbc.v42.WsJdbc42PreparedStatement#90069551'
and so on. Which doesn't help much in figuring out which queries are slow... Seems so that Hibernate just does a toString() on the prepared statement. See the source of org.hibernate.engine.jdbc.spi.SqlStatementLogger#logSlowQuery(Statement, long).
Is there a possibility to configure hibernate or liberty to output the real SQL? Do I have to implement an own statement wrapper?
Should I open a bug in hibernate?
Yes, you should open a bug against Hibernate for this. The assertion that PreparedStatement.toString will show the SQL is incorrect because there is no requirement within the JDBC specification or PreparedStatement JavaDoc that would guarantee or even recommend that behavior. The toString output that you see is pretty standard, following java.lang.Object.toString conventions of fully qualified class name # hexadecimal hash code.
WebSphere Application Server Liberty does have some options that can help you see the SQL queries and other JDBC operations. See the following section on enabling JDBC driver trace, which goes into detail depending on which database/JDBC driver you are using:
https://www.ibm.com/docs/en/was-liberty/nd?topic=liberty-enabling-jdbc-tracing
I now solved it via a custom ServiceContributor (referred to in META-INF/services/...) where I override the JdbcServicesInitiator and there, in turn, I override JdbcServicesImpl#configure to set a custom SqlStatementLogger.
In there, I use a method from the WSJdbcUtil class to refind the sql from the statement. Of course, I first need to load the class from an appropriate class loader (the one of the statement)... ugly but works.

convert (Translate ) from one sql syntax to another (from mssql to oracle,h2...)

The application that I started working on uses several databases with different SQL syntax for different clients (MsSQL,MySQL, oracle,h2 for JUnit tests...). Updating all databases(adding a new table) is a manual task.
I have tried several free tools that I found online to do the conversion from one syntax to another
http://www.sqlines.com/online
https://www.jooq.org/translate/
but they don't work well for triggers and datatypes.
My question is what would be the best way to automate this process of maintaining multiple databases for a single app, write SQL in just one syntax and convert to all others?
It is an older project so I cant use hibernate to generate the SQL for me.
Try This:
https://www.jooq.org/translate/
OR
There are a number of database tools that help migrating data from one to another database, for example:
Flyway
SQuirreL DB Copy Plugin

Generic ODBC remote source in SAP HANA SDI/SDA

Has anyone been able to create in SAP HANA a Generic ODBC remote source for a database other than MSSQL/Oracle/Netezza/ASE -- in other words, where you'd have to select a datasource "Generic ODBC" and then likely implement your own property/configuration file.
I'm trying to configure this on top of an Apache Drill ODNBC driver. I am able to successfully test System DSN using iSQL utility, but Remote Source creation fails with an error message citing problems loading the driver file -- a rather cryptic one.
I'm in the middle of an exchange with OSS, but so far they seem to be reluctant to accept it as a product fault. I'd like to see if there are successful cases for Generic ODBC in HANA at all.
I don't think it's supported.
Every ODBC source type must have all its capabilities described.
This is required to map datatypes, functions and features.
What you can do is replace an existing odbc source.
For instance you can change the file config/property_ntz.ini to create a valid description of the capabilities of apache drill. From the HANA side, just declare it as a netezza.
If it makes sense to support Apache drill, as an SAP employee myself I could trigger a discussion internally.

SQL - Attempted to read or write protected memory

I'm trying to use a functions on the SQL SSMS2014 and I get the error on the title.
I can create new tables and databases no problem if i do it with a new query, but afterwards i can't edit or use the design function without getting that error on any of the databases that i have.
Most of the similar errors i found were related to connection to the database, but none of the fixes on those worked for me.
My guess is that the error message you are getting is:
the backend version is not supported to design database diagrams or tables
Solution:
This is commonly reported as an error due to using the wrong version of SMSS. Use the version designed for your database version. You can use the command select ##version to check which version of sql server you are actually using. This version is reported in a way that is easier to interpret than than shown in the Help About in SMSS.
Using a newer version of SMSS than your database is generally error free, i.e. backward compatible.

Generic Command Line SQL Program?

Is there any application/project that provides you with a command line SQL client that will work with multiple databases and/or provides a mechanism for writing your own drivers?
Put another way, I'm looking for something like the mysql command line client or SQL*Plus for Oracle, but that's database agnostic.
All platforms welcome, but extra points for OS X/*nix approaches.
Try sqlsharp from the Mono subversion repository. You can define new providers via a configuration file. They are loaded from .NET assemblies, so you can write your own provider if you want to, but Mono already has MS SQL and Oracle, plus postgres and MySQL provide their own .NET assemblies.
It works on any platform supported by Mono and MS.NET.
Why not use something built on Perl and DBI like DBI-Shell?
a SQL client and front-end for multiple database is Crunchyfrog, which offers a Native Database Shell. Not sure if this meets your requriement