By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,558 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,558 IT Pros & Developers. It's quick & easy.

DB2 version without connection

P: n/a
What would be the best way to obtain a DB2 UDB (major) version for
particular DB2 database, preferably by the C language style API.

I have to develop a client application that first has to figure out a
DB2 UDB version (can be 5, 6, 7, or 8) for the DB2 database passed
dynamically as run time parameter to the application.

So first function should take a database name as a parameter and
return an integer (5, 6, 7, or 8, depending what is, for that
database, the DB2 version used). This function should not connect to
the database. I would use DB2 API that does not require a connection
to the database, I guess. Any level of complexity of API without a DB2
connection would be fine. I can not use CLI/ODBC or JDBC in this
function, but I may use all them after in the rest of application.

I think when you catalog a database, the DB2 version for the database
is stored locally on the client side, and I need to retrieve that,
perhaps using sqledgne - Get Next Database Directory Entry and related
API-s. I have not tried that because when I executed the DB2 command
LIST DB DIRECTORY (which is basically same) I am getting Database
release level a.00 (where Ďa' in the Ďa.00' is an ASCII 228
character), but should be 8.00 or something like that, so I am not
confident that this is a way to do that.

Please ask me for more detail if I have not explained this properly.
Nov 12 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a

"DB2SQL" <db****@sympatico.ca> wrote in message
news:3d*************************@posting.google.co m...
What would be the best way to obtain a DB2 UDB (major) version for
particular DB2 database, preferably by the C language style API.

I have to develop a client application that first has to figure out a
DB2 UDB version (can be 5, 6, 7, or 8) for the DB2 database passed
dynamically as run time parameter to the application.

So first function should take a database name as a parameter and
return an integer (5, 6, 7, or 8, depending what is, for that
database, the DB2 version used). This function should not connect to
the database. I would use DB2 API that does not require a connection
to the database, I guess. Any level of complexity of API without a DB2
connection would be fine. I can not use CLI/ODBC or JDBC in this
function, but I may use all them after in the rest of application.

I think when you catalog a database, the DB2 version for the database
is stored locally on the client side, and I need to retrieve that,
perhaps using sqledgne - Get Next Database Directory Entry and related
API-s. I have not tried that because when I executed the DB2 command
LIST DB DIRECTORY (which is basically same) I am getting Database
release level a.00 (where 'a' in the 'a.00' is an ASCII 228
character), but should be 8.00 or something like that, so I am not
confident that this is a way to do that.

Please ask me for more detail if I have not explained this properly.


I don't know how to accomplish what you want with the C API; I don't really
program in C any more so I don't know if it is possible or not.

You can get exactly what you want very easily with JDBC. The
getDatabaseMajorVersion() method in the DatabaseMetaData interface will
"retrieve the major version number of the underlying database", according to
the Java API. [You can also use getDatabaseMinorVersion() in the same
interface if you need to distinguish between V8.1 and V8.2 for example.]

However, this approach requires you to get a database connection first
though and I know you don't want that.

There *may* be a way to get the information without a database connection
but I don't know of any; all database accesses I've ever done has required a
connection first.

Rhino
Nov 12 '05 #2

P: n/a
DB2SQL wrote:
What would be the best way to obtain a DB2 UDB (major) version for
particular DB2 database, preferably by the C language style API.

I have to develop a client application that first has to figure out a
DB2 UDB version (can be 5, 6, 7, or 8) for the DB2 database passed
dynamically as run time parameter to the application.

So first function should take a database name as a parameter and
return an integer (5, 6, 7, or 8, depending what is, for that
database, the DB2 version used). This function should not connect to
the database. I would use DB2 API that does not require a connection
to the database, I guess. Any level of complexity of API without a DB2
connection would be fine. I can not use CLI/ODBC or JDBC in this
function, but I may use all them after in the rest of application.

I think when you catalog a database, the DB2 version for the database
is stored locally on the client side, and I need to retrieve that,
perhaps using sqledgne - Get Next Database Directory Entry and related
API-s. I have not tried that because when I executed the DB2 command
LIST DB DIRECTORY (which is basically same) I am getting Database
release level a.00 (where Ďa' in the Ďa.00' is an ASCII 228
character), but should be 8.00 or something like that, so I am not
confident that this is a way to do that.


How about using the "db2DbDirGetNextEntry" API? It uses the version
information as declared at the beginning of "sqllib/include/db2ApiDf.h",
i.e. the macros "db2Version6", "db2Version810" and so on.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #3

P: n/a
Knut Stolze <st****@de.ibm.com> wrote in message news:<cj**********@fsuj29.rz.uni-jena.de>...
DB2SQL wrote:
What would be the best way to obtain a DB2 UDB (major) version for
particular DB2 database, preferably by the C language style API.

I have to develop a client application that first has to figure out a
DB2 UDB version (can be 5, 6, 7, or 8) for the DB2 database passed
dynamically as run time parameter to the application.

So first function should take a database name as a parameter and
return an integer (5, 6, 7, or 8, depending what is, for that
database, the DB2 version used). This function should not connect to
the database. I would use DB2 API that does not require a connection
to the database, I guess. Any level of complexity of API without a DB2
connection would be fine. I can not use CLI/ODBC or JDBC in this
function, but I may use all them after in the rest of application.

I think when you catalog a database, the DB2 version for the database
is stored locally on the client side, and I need to retrieve that,
perhaps using sqledgne - Get Next Database Directory Entry and related
API-s. I have not tried that because when I executed the DB2 command
LIST DB DIRECTORY (which is basically same) I am getting Database
release level a.00 (where ?a' in the ?a.00' is an ASCII 228
character), but should be 8.00 or something like that, so I am not
confident that this is a way to do that.


How about using the "db2DbDirGetNextEntry" API? It uses the version
information as declared at the beginning of "sqllib/include/db2ApiDf.h",
i.e. the macros "db2Version6", "db2Version810" and so on.


Could you tell me where the db2DbDirGetNextEntry API is defined and
described (include file name would be appreciated). I can not find it
in the db2ApiDf.h or any other that I know. It is not in any book
(Administrative API Reference or similar).

Thank you very much.
Nov 12 '05 #4

P: n/a
DB2SQL wrote:
Knut Stolze <st****@de.ibm.com> wrote in message
news:<cj**********@fsuj29.rz.uni-jena.de>...
DB2SQL wrote:
> What would be the best way to obtain a DB2 UDB (major) version for
> particular DB2 database, preferably by the C language style API.
>
> I have to develop a client application that first has to figure out a
> DB2 UDB version (can be 5, 6, 7, or 8) for the DB2 database passed
> dynamically as run time parameter to the application.
>
> So first function should take a database name as a parameter and
> return an integer (5, 6, 7, or 8, depending what is, for that
> database, the DB2 version used). This function should not connect to
> the database. I would use DB2 API that does not require a connection
> to the database, I guess. Any level of complexity of API without a DB2
> connection would be fine. I can not use CLI/ODBC or JDBC in this
> function, but I may use all them after in the rest of application.
>
> I think when you catalog a database, the DB2 version for the database
> is stored locally on the client side, and I need to retrieve that,
> perhaps using sqledgne - Get Next Database Directory Entry and related
> API-s. I have not tried that because when I executed the DB2 command
> LIST DB DIRECTORY (which is basically same) I am getting Database
> release level a.00 (where ?a' in the ?a.00' is an ASCII 228
> character), but should be 8.00 or something like that, so I am not
> confident that this is a way to do that.


How about using the "db2DbDirGetNextEntry" API? It uses the version
information as declared at the beginning of "sqllib/include/db2ApiDf.h",
i.e. the macros "db2Version6", "db2Version810" and so on.


Could you tell me where the db2DbDirGetNextEntry API is defined and
described (include file name would be appreciated). I can not find it
in the db2ApiDf.h or any other that I know. It is not in any book
(Administrative API Reference or similar).


The include file in question is "db2ApiDf.h" in the sqllib/include/
directory. I don't know which piece you would have to install, though.
I'd guess it is the Application Development Client.

The documentation for the API can be found here in the DB2 manual:
http://publib.boulder.ibm.com/infoce...n/r0001492.htm

p.s: Given that this API is new in V8.2 (aka FP7), it might not necessary be
what you need if you want to detect a pre-V8 instance.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #5

P: n/a
You are right, I need an API that works with any version of DB2 UDB
client (version 5, 6, 7, or 8). The application does not know in the
advance what DB2 UDB client or server version is used and can not be
restricted in the advance.

I have a DB2 8.1.6 and the db2ApiDf.h is here but this API is not in
the db2ApiDf.h. Anyway, seems that this is just a new version of the
sqledgne - Get Next Database Directory Entry API, so it would,
perhaps, return same value of the dbtype (same name as dbtype in the
sqledinfo used in the sqledgne).

The bigger problem with this API (db2DbDirGetNextEntry - Get Next
Database Directory Entry) is that you have to provide a versionNumber
(Input Specifies the version and release level of the structure passed
in as the second parameter pParmStruct) as first parameter. Imagine
that, in order to obtain a dbtype (Database manager release
information) you have to provide a versionNumber (Input Specifies the
version and release level of the structure passed in as the second
parameter pParmStruct). Congratulation to DB2 API designers. You are
great. Please give me a value and I will design an API that is going
to return that value. And I will assign a smart advisor that is going
a help people in the public newsgroup to use that API. Seems that
there is still somebody enough smart in the DB2 team who hides that
API, so we can not find it yet.
Nov 12 '05 #6

P: n/a
DB2SQL wrote:
....
I have to develop a client application that first has to figure out a
DB2 UDB version (can be 5, 6, 7, or 8) for the DB2 database passed
dynamically as run time parameter to the application.

....

Please excuse my question here - but did you weighted pro's and cons of doing that?

Since V5, V6, and V7 are out of support - and should not be used in production
(unless customer signed and paid for a service extension; such extentions are
not very common; I don't believe that there is anybody using V5 and V6 service
extensions) - is it cost effective to develop new application which covers for
those version?

Curious person wants to know,

Jan M. Nelken
Nov 12 '05 #7

P: n/a
DB2SQL wrote:
The bigger problem with this API (db2DbDirGetNextEntry - Get Next
Database Directory Entry) is that you have to provide a versionNumber
(Input Specifies the version and release level of the structure passed
in as the second parameter pParmStruct) as first parameter. Imagine
that, in order to obtain a dbtype (Database manager release
information) you have to provide a versionNumber (Input Specifies the
version and release level of the structure passed in as the second
parameter pParmStruct). Congratulation to DB2 API designers. You are
great.
I think you have a big misunderstanding here. The manual reads very
specific: the "versionNumber" attribute is the "version and release level
of _the structure passed_ in as the second parameter pParmStruct".

I would also congratulate the API designers because they took into account
that the structure itself might change or might need to be enhanced in
future releases. With the requirement that you provide the version
information about the structure (not the database manager or databases),
DB2 will know what kind of information you did provide and will know what
to do.
Please give me a value and I will design an API that is going
to return that value.


No, the API says: Please give me a structure and tell me how this structure
looks like. If it is the structure we defined for V82, then I (DB2) know
how to handle it. If it is a structure of V10, then I know it is different
than V82 and I know how to handle that. In both cases, I can give you the
directory entries you want and we both know the "protocol" we are using.

--
Knut Stolze
Information Integration
IBM Germany / University of Jena
Nov 12 '05 #8

P: n/a
The High Majesty The Client paid for the product, it works, and they
do not want to fix or upgrade. That's 'Merica, not Europe.
Nov 12 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.