Showing posts with label netbeans. Show all posts
Showing posts with label netbeans. Show all posts

Sunday, November 22, 2015

NetBeans and DB2 again

So for various reasons (mainly the 64bit v 32bit problem with the native driver) I changed my DB2 JDBC driver to type 4, i.e. the Universal driver.
However, when I connect from NetBeans with an URL like jdbc:db2://localhost:50000/sample the schema would stay empty.
Nothing. Zip. Zilch. Zero.
Nada.
Quite some googling and debugging - mainly with a little java program like this:

import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;


public class MainDB2 {
    
    private static final String URL = "jdbc:db2://localhost:50000/SAMPLE";
    private static final String USER = "roman";
    private static final String PASSWORD = "pwd";
    private static final String SCHEMA = "roman";
    
  public static void main(String[] args) throws Exception {
        Class.forName("com.ibm.db2.jcc.DB2Driver");
        Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
        try {
            DatabaseMetaData dmd = conn.getMetaData();
            ResultSet rs = dmd.getTables(null, SCHEMA, "%", new String[] { "TABLE" });
            try {
                while (rs.next()) {
                    int count = rs.getMetaData().getColumnCount();
                    System.out.println("Column count: " + count);
                    int i;
                    for (i = 1; i <= count; i++) {
                        try {
                            System.out.println(rs.getString(i));
                        } catch (SQLException e) {
                            System.err.println("Exception reading column " + i);
                            e.printStackTrace();
                        }
                    }
                    System.out.println();
                }
            } finally {
                rs.close();
            }
        } finally {
            conn.close();
        }
    }
}



I was able to trace it back to an SQLCODE -443SQL0443N with diagnostic text "SYSIBM:CLI:-805". SQLSTATE=38553. Google this and you will get to here and learn that - again - a package was not bound, this time the db2schema.bnd file. Bind it as suggested in the article with the usual db2 bind db2schema.bnd blocking all grant public

and voila, NetBeans will find the schema.

Gets me every second year, it seams.

Tuesday, December 11, 2007

NetBeans 6.0 is out

and I installed it a couple of days ago.
Migration from 5.5 is pretty smooth (I only had to add the JAX-RPC WS plugin), and all projects compiled again.
I even noticed tons of nonsense in my code... Just in a couple of hours.

More on NB6 in the upcoming days, weeks, months.
Download NetBeans

Saturday, January 20, 2007

JDBC on DB2 UDB 8 stopped working

All of a sudden my netbeans would no longer connect to my DB2 UDB 8.1 database.
Got me a missing package error. So I tried all the usual db2rbind all and bind db2ubind.lst and db2cli.lst and whatnot (whatever I could remember from my DB2 days at IBM).

Still no help.

So I googled for the error message, and indeed IBM changed the package with a fixpak, the details can be found here at the IBM site.

Problem

After upgrading your server to DB2 UDB Version 8.1 FixPak 10 (also known as Version 8.2 FixPak 3), you will encounter an SQL0443N error if invoking a DB2 Call Level Interface (CLI) catalog function (such as SQLTables(), SQLColumns(), or SQLStatistics()). For example: SQL0443N Routine "SYSIBM.SQLTABLES" (specific name "TABLES") has returned an error SQLSTATE with diagnostic text SYSIBM:CLI:-805. SQLSTATE=38553

Cause
The CLI catalog functions execute routines on the DB2 UDB server. These routines use packages that are created by the db2schema.bnd bind file. The package name for db2schema.bnd has a different name in DB2 UDB Version 8.1 FixPak 10 than it did in previous fixpaks. If this bind file does not get bound to all of your existing databases on your server, you will get the SQL0443N error message.

Solution
As documented in the FixPak Readme file for DB2® Universal Database™ (DB2 UDB) Version 8.1 FixPak 10, you will need to bind the db2schema.bnd file locally against each database, as follows:


At a command prompt:
db2 terminate
db2 connect to
db2 bind /db2schema.bnd blocking all grant public sqlerror continue
db2 terminate

...where represents the name of a database to which the utilities should be bound, and where is the full path name of the directory where the bind files are located (usually sqllib/bnd).

The bind operation needs to be done within a local connection to the database.