Configure SQuirrel SQL Client to work for DB2/AS400 - sql

I use the ancient System i Navigator (french) to get to query a DB2 (AS/400) database.
I liked to update the client and use a more fresh (and English) sql client for that database.
So, I installed the SQuirrel SQL client (3.5.0, the latest at day).
After the installation and launching, I discovered that the "IBM DB2 App Driver" is not "checked".
The message when I click on it says:
"Could not find class COM.ibm.db2.jdbc.app.DB2Driver in neither the
Java class path nor the Extra class path of the IBM DB2 App Driver
driver definition: java.lang.ClassNotFoundException:
COM.ibm.db2.jdbc.app.DB2Driver"
As I understood I need to copy a (universal?) JDBC driver in the SQuirrel "\lib" folder. How to get it?
I don't have any "classpath" defined in the environmental variables (I am on Windows 7 x64).
I am not a Java developer, so I am not sure if I need or not to configure that classpath to make work that sql client.

if it's an AS400, then you should use JTOpen libraries to connect.
http://jt400.sourceforge.net/
JT400 has the JARS you need to use. Note, the class name mentioned above is not the same as what is expected on the AS400....
I remember it being something like this....
com.ibm.as400.access.AS400JDBCDriver... you'll want to double check
if you start squirrel-sql on the commandline you can add this
set CLASSPATH=%CLASSPATH%;c:/jt400.jar

If want a really quick and easy "command-line" JDBC client, you can use the one included in the JTOpen. I use it all the time so I don't have to open yet another window.
Here is an example.
~> java -cp jt400.jar com.ibm.as400.access.jdbcClient.Main jdbc:as400:AS400 SYSTEM USERID PASSWORD
>select * from sysibm.sysdummy1
IBMREQD
Y

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.

How to run sql from a Mac

I have a MacBook Pro and want to learn more about sql, I understand I cannot run sql from a Mac, what should I install VMware, linux, windows 10? Can someone walk me through this
SQL is just domain specific language (primarily) for relational databases. What you need to decide is what RDBMS, which in turn implements SQL, you would like to use.[1] Standalone implementations like SQLite definitely run on the Mac (many of Apple's own applications like Mail use it as their database.) For the more complex client/server RDBMS systems (i.e. Oracle, SQL Server, MySQL/MariaDB, etc.) you will at least need to install client-side drivers (often in the form of ODBC, JDBC or native drivers) and then either connect to an existing[1] database or install your own database server.
Since it sounds like you're just getting started, I'd highly recommend starting with a standalone database such as SQLite which you should be able to get to by opening a terminal window and typing 'sqlite3' at the prompt. This will allow you to jump right in and focus on learning SQL itself rather than dealing with getting a full-blown client/server database server up and running. (move on to that later if you find it needed/interesting/useful to you)
[1] unless you need to use an existing database, at work for example, in which case you'll need to find out the various details about the server and database in order to connect to it. In this case, you'll need to find a point of contact (often a DBA) to provide this information.

Where to download sun.jdbc.odbc.JdbcOdbcDriver (trying to connect output csv from Spoon to SSMS)

I have a csv that I have transformed in Kettle/Spoon/PDI and I am trying to output it to SSMS.
In Spoon, it's a two step process: read the csv (and edit a couple types), then output to SQL.
I get this error: "Driver class 'sun.jdbc.odbc.JdbcOdbcDriver' could not be found, make sure the 'MS SQL Server' driver (jar file) is installed.
sun.jdbc.odbc.JdbcOdbcDriver"
I can't seem to find where to download this driver. (Have googled it obviously, though perhaps not enough.)
http://www.java2s.com/Code/JarDownload/jdbc/jdbc.jar.zip
link to download sun.jdbc.odbc.jdbcodbcdriver jar file
I think the fact is not specific related to pentaho, else, to Java. The native connection type for java is JDBC, since Java 8, ODBC support was removed, so you may need jdbc2odbc bridge driver to connect ODBC datasources, but as far as I know, the only working solution is not open.
You can see more details here.

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.

Connect to Vertica from Datagrip

I'm using DataGrip and I'm kind of new in it. There is a case for me to connect to Vertica DB. As far as I know, there is no native provided driver for connection to that type of databases. What steps should I take to connect to it? Is there some driver to deal with?
Thanks!
You should be able to add the Vertica jdbc jar as a driver. Download it from the Vertica site, then:
Go to File / Data Sources
Right click somewhere and click Add / Driver
Give it a name
Select the jdbc jar file you downloaded
Set the class to com.vertica.jdbc.Driver
Dialect: PostgreSQL
As for how well this works, I'm not sure. It really depends on how DataGrip uses jdbc. But this is how you would add it.
In addition to #woot answer
I would add that when you setup the datasource connection to Vertica. Set the URL with below format.
URL: jdbc:vertica://{HOST}:{PORT}/{DB}