IBM Support

The name of a DB2 JDBC application appears as "db2jcc_application". How to change it?

Question & Answer


Question

Applications that use the IBM Data Server Driver for JDBC and SQLJ (sometimes called the JCC driver, or the JDBC Universal Driver) using type 4 connectivity show up in an application snapshot and in output of LIST APPLICATIONS with their application name as "db2jcc_application". How can I make them show up with a more descriptive application name?

Answer

Call the setClientProgramName method of the com.ibm.db2.jcc.DB2DataSource class and pass to it the application name as you want it to appear.

For example, the following program connects to a database so that the application name appears as "My application".




import java.io.*;
import java.sql.*;              
                                                                     
public class Demo
{                                                                      
   public static void main(String[] args)                            
   {                                                                  
       Connection conn = null;                                        
                                                                     
       try                                                            
       {                                                              
           com.ibm.db2.jcc.DB2DataSource ds =

              new com.ibm.db2.jcc.DB2DataSource();                                      
                                                                     
           ds.setDriverType(4);
           ds.setServerName("localhost");                            
           ds.setPortNumber(50000);                                  
           ds.setDatabaseName("sample");                              
           ds.setUser("username");                                  
           ds.setPassword("password");                              
            ds.setClientProgramName("My application");                         
                                                                     
           conn = ds.getConnection();                                
                                                                     
           System.out.println("Connected. Press a key to continue...");                                                                
           BufferedReader stdin =

             new BufferedReader(new InputStreamReader(System.in));                                        
           int ch = stdin.read();                                    
       }                                                              
       catch (Exception e)                                            
       {                                                              
           if (e.getMessage() != null)                                
           {                                                          
               System.out.println(e.getMessage());                    
           }                                                          
           e.printStackTrace();                                      
       }                                                              
       finally                                                        
       {                                                              
           if (conn != null)                                          
           {                                                          
               try                                                    
               {                                                      
                   conn.close();                                      
               }                                                      
               catch (SQLException e) {}                              
           }                                                          
       }                                                              
   }                                                                  
}



When you run the above program in one window, and leave it connected to the database, then run LIST APPLICATIONS in another window, it displays the application name as "My application".

If you run the same program except with the call to setClientProgramName removed, and leave it connected to the database, then run LIST APPLICATIONS in another window, it displays the application name as "db2jcc_applica", which is "db2jcc_application" truncated to fit into the displayed column size.

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Programming Interface - JCC","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF012","label":"IBM i"},{"code":"PF016","label":"Linux"},{"code":"PF025","label":"Platform Independent"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5;9.1;10.1;10.5;11.1","Edition":"Enterprise Server;Express;Personal;Personal Developer's;Workgroup Server","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
23 June 2018

UID

swg21407817