Obtaining the application handle from the connecting application -- Java??? 
Author Message
 Obtaining the application handle from the connecting application -- Java???
Hi Forum,
How can an a java application obtain its application handle (as identified
by DB2) once the application connects to the database?  From the command
line one can obtain the handle ids of each application connected to a
database (I am referring to the command LIST APPLICATIONS FOR ...).  I would
like to retrieve this information from the application connecting to the
database to make this information known to other objects in the application.


Mon, 09 Aug 2004 22:35:59 GMT
 Obtaining the application handle from the connecting application -- Java???

The only way I know to purely do it in Java is this:

1) write (or modify the one of examples in sqllib\samples\java) a Java
DB2GENERAL UDF that retrieves the applid with the getDBapplid() method
2) in the application do a "values myApplidUDF()"

There's no built-in support for that.

Hope this helps, Dirk


Quote:
> Hi Forum,
> How can an a java application obtain its application handle (as identified
> by DB2) once the application connects to the database?  From the command
> line one can obtain the handle ids of each application connected to a
> database (I am referring to the command LIST APPLICATIONS FOR ...).  I
would
> like to retrieve this information from the application connecting to the
> database to make this information known to other objects in the
application.



Tue, 10 Aug 2004 01:46:08 GMT
 Obtaining the application handle from the connecting application -- Java???
Thank you for your response Dirk.  I was thinking that one could call a DB2
API (which in turn would return the application handle) with SQLJ.  I have
not used SQLJ so I sought the feedback from the forum.  From your response,
it sounds that this is not possible.  Right?



Quote:
> The only way I know to purely do it in Java is this:

> 1) write (or modify the one of examples in sqllib\samples\java) a Java
> DB2GENERAL UDF that retrieves the applid with the getDBapplid() method
> 2) in the application do a "values myApplidUDF()"

> There's no built-in support for that.

> Hope this helps, Dirk



> > Hi Forum,
> > How can an a java application obtain its application handle (as
identified
> > by DB2) once the application connects to the database?  From the command
> > line one can obtain the handle ids of each application connected to a
> > database (I am referring to the command LIST APPLICATIONS FOR ...).  I
> would
> > like to retrieve this information from the application connecting to the
> > database to make this information known to other objects in the
> application.



Tue, 10 Aug 2004 02:35:13 GMT
 Obtaining the application handle from the connecting application -- Java???
Hi Carlos,

That is not what Dirk said:
getDBapplid() is the Java API. A three line JAVA UDF can expose this to SQL.
Look for posts by Knut Stolze on google.
He actually posted the code here some 4 weeks ago.

Cheers
Serge

--
Serge Rielau
DB2 UDB SQL Compiler Development
IBM Software Lab, Canada



Tue, 10 Aug 2004 03:28:02 GMT
 Obtaining the application handle from the connecting application -- Java???
Here you go:

store this into ApplIDUdf.java:

class ApplIDUdf extends COM.ibm.db2.app.UDF {
public void getApplID(String result) throws Exception {
    set(1,getDBapplid());

Quote:
}
}

compile it and copy ApplIDUdf.class to sqllib\function and then do a
"db2 -t" and copy and paste this into the command line processor:

connect to sample;
create function getApplID ()   returns VARCHAR(100)
 not fenced no sql no external action
 language java parameter style db2general
dbinfo external name 'ApplIDUdf.getApplID';
values (getApplID ());

Dirk


Quote:
> Hi Carlos,

> That is not what Dirk said:
> getDBapplid() is the Java API. A three line JAVA UDF can expose this to
SQL.
> Look for posts by Knut Stolze on google.
> He actually posted the code here some 4 weeks ago.

> Cheers
> Serge

> --
> Serge Rielau
> DB2 UDB SQL Compiler Development
> IBM Software Lab, Canada



Tue, 10 Aug 2004 05:16:16 GMT
 Obtaining the application handle from the connecting application -- Java???
Thank you very much.  I will try this ASAP.
Regards


Quote:
> Here you go:

> store this into ApplIDUdf.java:

> class ApplIDUdf extends COM.ibm.db2.app.UDF {
> public void getApplID(String result) throws Exception {
>     set(1,getDBapplid());
> }
> }

> compile it and copy ApplIDUdf.class to sqllib\function and then do a
> "db2 -t" and copy and paste this into the command line processor:

> connect to sample;
> create function getApplID ()   returns VARCHAR(100)
>  not fenced no sql no external action
>  language java parameter style db2general
> dbinfo external name 'ApplIDUdf.getApplID';
> values (getApplID ());

> Dirk



> > Hi Carlos,

> > That is not what Dirk said:
> > getDBapplid() is the Java API. A three line JAVA UDF can expose this to
> SQL.
> > Look for posts by Knut Stolze on google.
> > He actually posted the code here some 4 weeks ago.

> > Cheers
> > Serge

> > --
> > Serge Rielau
> > DB2 UDB SQL Compiler Development
> > IBM Software Lab, Canada



Tue, 10 Aug 2004 22:33:15 GMT
 Obtaining the application handle from the connecting application -- Java???
Hi Dirk,
How can I check that I have configured my server (Linux Mandrake) properly?
I followed the instructions of your e-mail, AlllIDUdf.java compiled well,
and
the UDF was created (I believe) well.  But when I executed
values(getApplID()), I got the following message: "1-----------SQL4300N Java
support is not installed or properly configured on this platform.
SQLSTATE=42724"

I check the DB2 help on this SQL message and the help says that in order to
run UDFs, one has to add the JDK's installation path to JDK11_PATH.  I did
so with the command "update dbm cfg using... ".  I also checked the
configuration of the DBM and the JDK11_PATH=/usr/jdk118 (where the JDK
resides).  However, when I ran the values(...) command I got the same error
message.

I am also able to compile the class in the server by issuing "javac
ApplIDUdf.java" with no problem and I am also able to run a test java
("Hello World") class in the server.  So I think that I have configured my
server properly
to compile and run java classes but I am still missing something to run UDF
classes.
Regards,



Quote:
> Here you go:

> store this into ApplIDUdf.java:

> class ApplIDUdf extends COM.ibm.db2.app.UDF {
> public void getApplID(String result) throws Exception {
>     set(1,getDBapplid());
> }
> }

> compile it and copy ApplIDUdf.class to sqllib\function and then do a
> "db2 -t" and copy and paste this into the command line processor:

> connect to sample;
> create function getApplID ()   returns VARCHAR(100)
>  not fenced no sql no external action
>  language java parameter style db2general
> dbinfo external name 'ApplIDUdf.getApplID';
> values (getApplID ());

> Dirk



> > Hi Carlos,

> > That is not what Dirk said:
> > getDBapplid() is the Java API. A three line JAVA UDF can expose this to
> SQL.
> > Look for posts by Knut Stolze on google.
> > He actually posted the code here some 4 weeks ago.

> > Cheers
> > Serge

> > --
> > Serge Rielau
> > DB2 UDB SQL Compiler Development
> > IBM Software Lab, Canada



Mon, 16 Aug 2004 21:40:57 GMT
 Obtaining the application handle from the connecting application -- Java???
I'm not an expert on DB2 on Linux. Try this:
http://www-1.ibm.com/support/manager.wss?rs=0&rt=0&org=SW&doc=1008742

and search on groups.google.com . I've seen this problem coming up a lot.

Dirk


Quote:
> Hi Dirk,
> How can I check that I have configured my server (Linux Mandrake)
properly?
> I followed the instructions of your e-mail, AlllIDUdf.java compiled well,
> and
> the UDF was created (I believe) well.  But when I executed
> values(getApplID()), I got the following message: "1-----------SQL4300N
Java
> support is not installed or properly configured on this platform.
> SQLSTATE=42724"

> I check the DB2 help on this SQL message and the help says that in order
to
> run UDFs, one has to add the JDK's installation path to JDK11_PATH.  I did
> so with the command "update dbm cfg using... ".  I also checked the
> configuration of the DBM and the JDK11_PATH=/usr/jdk118 (where the JDK
> resides).  However, when I ran the values(...) command I got the same
error
> message.

> I am also able to compile the class in the server by issuing "javac
> ApplIDUdf.java" with no problem and I am also able to run a test java
> ("Hello World") class in the server.  So I think that I have configured my
> server properly
> to compile and run java classes but I am still missing something to run
UDF
> classes.
> Regards,



Tue, 17 Aug 2004 02:29:21 GMT
 Obtaining the application handle from the connecting application -- Java???
Hi Dirk,
Indeed, the missing links were the problem.  The e-mail that you sent me
revealed the issue, I created the links as it says in the DB2 help, and,
voila, the UDF worked.
Thanks very much for your help.
Regrds,



Quote:
> I'm not an expert on DB2 on Linux. Try this:
> http://www-1.ibm.com/support/manager.wss?rs=0&rt=0&org=SW&doc=1008742

> and search on groups.google.com . I've seen this problem coming up a lot.

> Dirk



> > Hi Dirk,
> > How can I check that I have configured my server (Linux Mandrake)
> properly?
> > I followed the instructions of your e-mail, AlllIDUdf.java compiled
well,
> > and
> > the UDF was created (I believe) well.  But when I executed
> > values(getApplID()), I got the following message: "1-----------SQL4300N
> Java
> > support is not installed or properly configured on this platform.
> > SQLSTATE=42724"

> > I check the DB2 help on this SQL message and the help says that in order
> to
> > run UDFs, one has to add the JDK's installation path to JDK11_PATH.  I
did
> > so with the command "update dbm cfg using... ".  I also checked the
> > configuration of the DBM and the JDK11_PATH=/usr/jdk118 (where the JDK
> > resides).  However, when I ran the values(...) command I got the same
> error
> > message.

> > I am also able to compile the class in the server by issuing "javac
> > ApplIDUdf.java" with no problem and I am also able to run a test java
> > ("Hello World") class in the server.  So I think that I have configured
my
> > server properly
> > to compile and run java classes but I am still missing something to run
> UDF
> > classes.
> > Regards,



Tue, 17 Aug 2004 06:20:59 GMT
 
 [ 9 post ] 

 Relevant Pages 

1. accessing Application Handle from CLI application

2. How talk to a Java application from a C++ application

3. IL-Peoria-53650--Object Oriented Devel.-C++-Java-UNIX-ORACLE-Web Applications-Application Developer

4. connecting a java-application to sqlserver2k

5. Connecting to SQLServer in Java Application

6. How can i connect java application to SQL Server 2000

7. Java Applet or Application to Connect to Informix / MsAccess Database

8. Connecting to an Access database from java application (NOT applet)

9. Java Applet/Application to Connect to Access or SQL Server

10. How to connect FMP to Java application?

11. APPLICATION DEVELOPER/ Intranet Applications, Extranet applications- WA

12. APPLICATION DEVELOPER/ Intranet Applications, Extranet applications- WA


 
Powered by phpBB® Forum Software