Connecting to DB2 using SQL Developer - db2

I trying to connect to DB2 database through SQL Developer. I followed following steps create connection:
1. Open SQL Developer
2. Go to Tools > Preferences > Database > Third Party JDBC Drivers.
3. I added third-party JDBC driver path entries (db2jcc.jar and db2jcc_license_cu.jar)
As soon as I try to create connection I get below error

Oracle SQL-Developer Version 17.2 works fine for me with Db2 Version 11 for Linux x64 and I am using a recent Type-4 jdbc (db2jcc4.jar) driver from IBM.
You question shows that your Db2 jdbc driver version is very old (Version 9.7 fixpack 5) and out of support, so you should upgrade to the latest available Db2 client for your (unspecified) operating-system. Also you should ensure you are using the latest release of the Oracle-SQL-Developer for your operating system.
As your question gives no facts about your versions of Oracle or Db2 products or operating systems, this is the best advice that is possible.

I got the same problem, it turned out SQL Developer doesn't display tables for DB2, but still allows to perform SQL queries. If you know table names, you will be able to select data from those tables if you have enough permissions to do so.
You can test ability to perform SQL queries by selecting DB2 version (SQL below is valid for DB2 12.0)
SELECT GETVARIABLE('SYSIBM.VERSION') AS VERSION FROM SYSIBM.SYSDUMMY1;
Make sure you don't forget to specify schema while selecting data from your tables!
select * from schema.table_name;

Related

Migrate from db2 9.7 express-c to db2 11.5 developer

I have an old application handling data on a DB2 server (Linux version, 9.7 express-c) and I need to upgrade the server. I searched on the IBM site and I found that the last "free" version (11.5) is the only one available, but I cannot restore a backup taken from a 9.7 directly into the 11.5.
Is there any other way instead of using db2look and db2move?
Do anyone know if it's possible to find the 11.1 developer Linux version?
You can download the server-fixpack via https://www.ibm.com/support/pages/node/6427871
( IBM registration is required ),
This is an indirect way to IBM passport advantage website. It's important to choose the "DB2 Server Fix Pack" as distinct from other images. It is wise to always download the most recent fixpack for the release when using the Server-Fixpack, these fixpacks are cumulative and do not require the base version to be preinstalled.
You can get a trial license with it and just do the intermediate restore (from the v9.7 backup-image into a disposable Db2 v11.1 instance, then backup that database offline and copy the image to a place accessible to your Db2 v11.5 new instance.
You can then drop the v11.1 db2instance, and uninstall the Db2 v11.1 product.
Finally restore that Db2 v11.1 backup image into your Db2 v11.5 instance. This will upgrade the database to the Db2 v11.5 release, consider running db2updv115 afterwards, and revalidating all objects with SYSPROC.ADMIN_REVALIDATE_DB_OBJECTS etc.
Whether the above indirect method is quicker (or easier) than using db2move to export and load, will depend on the complexity of your database. Worth checking...if your Db2 v9.7 instance is still running of course.
Other methods are possible, if you want to spend $$ on recovery tools that extract data from backup images.

How can I tell SQLDeveloper which version of JDBC to use?

I need to connect to an Oracle 9i server from my machine using SQLDeveloper. I already have a functioning version of SQLDeveloper 18.2 + Oracle Client 12 for more modern databases, but for this connection I want a separate older version of SQLDeveloper.
I've installed SQLDeveloper 3.2.20.09 in a separate folder on my machine and can launch it, but it defaults to finding the ojdbc6.jar file from Oracle Client 12. if I go to Help > About and select properties, the jdbc.library says jdbc.library /C:/app/client/product/12.1.0/client_1/jdbc/lib/ojdbc6.jar
and if I try to connect I get the error ORA-01460: unimplemented or unreasonable conversion requested
I tried putting the path to the SQL Developer 3.2 install first in the PATH variable, but no difference. Is there a way to tell SQL Developer which jdbc driver to use for Oracle ? (maybe in sqldeveloper.conf)
The official answer is:
use the jar (driver) we ship with the product OR
use a Thick Client, and we'll pull the jdbc driver from an Instant Client or Oracle HOME on your machine
The 2nd option will work so long as you don't try to go back back or forward in time to the point that the software will recognize/support the driver.
In other words, you can't tell SQL Developer 18.x to use a 9i Home, we have a hard dependency to require at least a 11gR2 client (I believe, it could actually be a 12c based client which is required).
You'd be better off getting your data out of that ancier 9i Database and into a modern 12 or 19c Oracle instance.
but it defaults to finding the ojdbc6.jar file from Oracle Client 12.
Sounds like you've managed to get a thick connection defined, go into preferences and disabled on the advanced page any reference to OCI or Thick, then it will use the jdbc driver shipped with SQLDev.

How to change default JDBC driver of Oracle SQL Developer?

I have an old Oracle 9i r2 database. The last JDBC driver that I managed to make work with it is ojdbc6 11.2.0.4. This keeps me stuck to SQL Developer 4.0.3. I would like to benefit from features of newer versions of SQL Developer. But they use newer driver like ojdbc8.
Is there a way to use old drivers with new versions of SQL Developer? The option to add third party JDBC drivers only work to add drivers for other databases like db2 or sql server.
I tried to delete the recent driver and replace it by an older one but SQL Developer malfunctions.
For SQL Developer version 20.2.0 on Windows 10 do:
Download and unzip SQL Developer version 20.2.0
Download and unzip Oracle Instant Client 11.2.0.4.0
Configure SQL Developer to use above instant client:
Tools > Preferences... > Database > Advanced
Mark "Use Oracle Client" > Configure...
In "Client Type" select "Instant Client"
In "Client Location" point to where you unziped instant client
Click "Test...". The log panel should show something like
Testing loading Oracle JDBC driver ... OK
Testing checking Oracle JDBC driver version ... OK
OK > restart SQL Developer
Configure connection:
Just create a normal connection
In "Advanced" tab add the key oracle.jdbc.timezoneAsRegion with value false. This avoids
ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region not found
This procedure enables you to use a more recent SQL Developer version with an old Oracle 9i r2 without hanging on connect or getting
ORA-01460: unimplemented or unreasonable conversion requested
every time you click something.

DB2 connectivity without client drivers

I'm using EF 6 (Code first) with the IBM.Data.DB2.EntityFramwork nuget package to access a db2 database server. Working locally it all works as expected, but when deployed to a test server I get an exception: "System.MissingMethodException: Method not found: 'Void IBM.Data.DB2.InternalStruct6.SetDefault()"
I'm no DB2 wizard but I think the issue is related to a incompatible version of the db2 client drivers installed on the test server (9.7?). Entity framework 6 support needs version > 10.5. (I must have installed the 10.5 version locally at some point).
It would be nice to be able to run the application on any pc without additional dependencies, so my question is: Are there any way of skipping the db2 clients/drivers installation, and rather reference certain db2 dll's (or other nuget packages), to access db2 db servers?
Ok, I think asking the question resulted in a moment of enlightenment.
I guess the answer is NO, as the db2 clients/drivers actually installs the db2 odbc data source driver for db2. (Located in Administrative Tools -> Data Sources (ODBC)).

IBM DB2 Type 4 driver?

Where can I find the redistributable version of the IBM DB2 Type 4 driver?
I suppose this is the driver I would use to connect from a Java app (on windows) to DB2 on the mainframe?
You will not be able to connect to the mainframe with any redistributable JDBC driver. The driver pack consists of the actual type 4 driver (db2jcc.jar) and any number of license files of the form:
db2jcc_license_cisuz.jar
where the cisuz bit is variable, indicating the platforms that you're allowed to run on (iSeries, pSeries, System z, LUW and so on).
You're only likely to get cu with any freely distributable pack. You need the z to access DB2 on the mainframe and that's jealously guarded so you'll need to purchase a specific edition of DB2 Connect to get it. I think both PE and EE, the personal and enterprise editions, have this licence file.
Without that license file, the type 4 driver won't even try to talk to the server, you'll get an exception.
IBM's Fix pack site has the "IBM Data Server Driver for JDBC and SQLJ" which is nothing but the JDBC type 4 driver. Though the page I pointed to above happens to be the windows page, it's the same type 4 driver for all platforms, as should be expected.
I don't think any user/password is required.
There is no need to download the JDBC driver separately it is already shipped with your DB2 product.
You can easily find it at this location : C:\Program Files\IBM\SQLLIB\java\db2jcc.jar
db2jcc.jar is the driver name
You can get the drivers from the IBM site. You will need to have IBM ID and password to login (which you can obtain here). Zip file is about 7 MBs, in contains DB2 9.5 JDBC (type 2/4) and SQLJ drivers. Type 4 drivers are in db2jcc4.jar.
However, you won't be able to connect to mainframes with this driver if mainframe is running DB2 for z/OS. To do so, you need at least to purchase DB2 Connect product, which will cost you about $500 minimum.
If you're running on an AS/400 (or iSeries, or whatever the heck IBM is calling it these days), you'll probably want to get it from JTOpen.
Their toolbox replaces the old Java Toolbox and includes the JDBC drivers.
If I need any IBM JARs for DB2 or MQ, I usually just add it to the instructions that DB2 or MQ needs to be installed as a prerequisite along with a URL to download it.
The same goes for Java and many other not easily redistributable products as well.
This eliminates the need to worry about licensing issues as it would be on the onus of the user rather than the vendor to obtain the proper licenses.