A fix to prevent the increase in the number of DB connections in the custom authentication provider of the Cognos SDK sample

Overview

In the Cognos Analytics SDK, there is a sample of a custom authentication provider that performs Cognos authentication in a Java program. * See below for custom authentication. ** Cognos Custom Authentication Setup Procedure ** https://qiita.com/shinyama/items/1f9c7842a3966233a5d7

In this sample program, I recently encountered some problems with endless connections to the database of the authentication source, which consumes a lot of Db2 memory.

Since this program is provided as a sample, it is provided on the premise that it is your own responsibility to use it in the production environment, but there are many projects that are actually used, and I am troubled with the same problem. I think there are many projects, so I will post them.

Coping

In queryImpl () of QueryUtil.java program, it is necessary to add the following "<-add" part and close statement and resultSet. Regarding connection, if you explicitly close it in the program, an authentication error will occur, so do not explicitly close it. However, connections that are no longer needed will be released at the time of the Cognos built-in WebSphere Liberty GC.

		try (final PreparedStatement statement = connection.prepareStatement(sql))
		{
			for (int i = 0; i < parameters.length; ++i)
				statement.setObject(i + 1, parameters[i]);

			try (final ResultSet resultSet = statement.executeQuery())
			{
				if (includeMetadata)
					data.add(QueryUtil.getMetaDataRow(resultSet));

		while (resultSet.next()) 
            		data.add(QueryUtil.getDataRow(resultSet)); 
 
 		resultSet.close();   <-add to
                }
 		statement.close();   <-add to
        } 
        catch (final SQLException ex) 
        { 
            throw new UnrecoverableException("SQL Exception", "An exception was caught while querying the authentication database."); 
        } 


<2018/6/29 postscript> In addition to the above SDK program fix, I found that changing the WebSphere Liberty GC policy built into Cognos will free up a large number of DB sessions before they accumulate, so I added it. Put.

For Linux, change the GC in the following file. /opt/ibm/cognos/analytics/bin64/bootstrap_wlp_linuxi38664.xml

Change the gencon here and restart Cognos. <param condName="${java_vendor}" condValue="IBM">-Xgcpolicy:gencon</param>

In that case, I changed it to "Balanced". https://www.ibm.com/developerworks/jp/websphere/library/was/was8_gc/2.html

If you want to use Restorable JDBC Sample and JDBC Sample with custom authentication, please remember this article.

Recommended Posts

A fix to prevent the increase in the number of DB connections in the custom authentication provider of the Cognos SDK sample
A description of the JDBC Sample that will be helpful when developing a custom authentication provider with the Cognos SDK
Pursuing the mystery that the number of DB connections in Tomcat increases to only 8-A day of an OSS support engineer
Dynamically increase the number of elements in a Java 2D array (multidimensional array)
Sample code to assign a value in a property file to a field of the expected type
Count the number of occurrences of a string in Ruby
Considering the adoption of Java language in the Reiwa era ~ How to choose a safe SDK
A program that counts the number of words in a List
Find the number of days in a month with Kotlin
802.1X authentication to the network of Bonding setting in CentOS7
[Swift] When you want to know if the number of characters in a String matches a certain number ...
Fix the file name of war to the one set in Maven
I tried to make a sample program using the problem of database specialist in Domain Driven Design
Remote debugging of the Cognos SDK
The story of forgetting to close a file in Java and failing
How to change the maximum and maximum number of POST data in Spark
How to find the total number of pages when paging in Java
Sample program that returns the hash value of a file in Java
How to change the value of a variable at a breakpoint in intelliJ
How to get the absolute path of a directory running in Java