PostgreSQL JDBC Driver – Upper Limit on Parameters in PreparedStatement

A lesser known limit of the PostgreSQL JDBC driver is the passing of at most 32767 variables into a PreparedStatement. This upper bound value on the number of parameters is derived from the maximum value of the signed Short data type in Java. In this post, I will show that this limit is not present when using the psql CLI client to connect directly to the PostgreSQL database, and only appears when using the JDBC driver. Subsequently I will suggest ways to address this limit.

Whiteboard Coding: Using Hash Tables to Reduce Algorithm Time Complexity by Tracking State

Overview A hash table can reduce the time complexity of an algorithm by tracking state of input elements. In this post, I will explain the gist of the problems and how a hash table improves a naive solution. Problem #1 Description There is a large 2D array of arbitrary object type with length m and … Continue reading Whiteboard Coding: Using Hash Tables to Reduce Algorithm Time Complexity by Tracking State

Logging in Java Applications (Using java.util.logging Package)

Having a logging component within a library or service (especially in a microservices architecture) is useful to the downstream applications that use it. When properly set up, it allows them to choose their own logging implementation, and level of verbosity, without having to recompile the code. While there are many different logging implementations (e.g. log4j, … Continue reading Logging in Java Applications (Using java.util.logging Package)

Late Night Coding – With and Without Git Rebase

Typical code repositories usually have the following branches (with multiple synonyms): master/production - a version of code that your actual customers use beta - a version of code that is used for UAT or just A/B testing alpha/pre-release - a version of code used for end-to-end and/or integration testing development - a version of code … Continue reading Late Night Coding – With and Without Git Rebase

Benchmarking an API’s Response Time

In order to provide response time estimates for an API service, I used two tools, namely Postman (a third party application), and cURL. The latter was used because it gave a more accurate time estimate. Target API Server REST API server powered by Node.js and the Express Web Application Framework Runs on free public tier … Continue reading Benchmarking an API’s Response Time

Windows Batch Script – Rename/Prepend and Change Extension of Files

I'm sharing a simple one liner Windows batch script to rename/prepend the filename, and change the extension of files (that match a pattern) within a folder. I take no credit for this script, as I was inspired by the post found on Stack Overflow here: https://stackoverflow.com/questions/8780097/renaming-files-in-cmd-using-wildcards The script is as follows: for %%f in (*.html) … Continue reading Windows Batch Script – Rename/Prepend and Change Extension of Files

Late Night Coding – Ternary if Operator

Midnight coding often results in weird/roundabout logic, such as the one expressed below. It is a snippet from a simple REST API server that uses Nodejs and the Express framework. app.post ('/dashboard', function (req, res) { var reqBody = req.body if (reqBody.hasOwnProperty('transactionID') && reqBody.hasOwnProperty('errorCode')){ res.status(reqBody.errorCode).json(ErrorHandler(reqBody.transactionID, reqBody.errorCode)) }) function ErrorHandler (transactionID, errorCode) { if (errorCode == … Continue reading Late Night Coding – Ternary if Operator