This is to be expected, but I had never seen it. I increased the batch size on a JDBC batch insert to 100,000 (yes, go ahead and laugh :)), and hit the exception below. As I noted, it makes sense,…
Category: Java
JDBC and Oracle Database Change Notification
Below is a simple example of a cutdown example of using DCN in Oracle with JDBC. I plan on presenting this to our developers as an alternative to the ATG InventoryCache manager module. import java.sql.*; import java.util.*; import oracle.jdbc.*; import…
Finding java thread consuming CPU
Periodically, we will have an application server go to 100% CPU utilization on a single java process. Below is the methodology I use to troubleshoot a high CPU thread consumer in java. 1. As the user running the Java Virtual…
awk script to print blocked threads in a java thread dump
-bash-4.1$ cat blocked_threads.awk #!/bin/awk -f { if ($0 ~ “- locked” || $0 ~ “- waiting to lock”) { s[i++]=$0 } } END { for (i in s) { if (s[i] ~ “waiting to lock”) { split(s[i],t) for (j in…
Print thread dump for a single thread
We had an issue where a single thread was using all the CPU. We wanted to check it at the command line while troubleshooting. We used what is below… [atg@CMHLDECOMAP01 ~]$ jstack 3000 | awk ‘{if ($1 == “\”Thread-9\””) {i…
Java date difference in milliseconds
Every time I need to do math on a date in java, I end up googling it. While that isn’t the worst way to do things (hey, it’s probably how you found this :)), I wanted something I *knew* would…
Query SQL Server stored procedure text with JDBC
I needed to quickly print the text associated with several stored procedures across multiple database servers to individual files. I used what is below. import java.sql.*; import com.microsoft.sqlserver.jdbc.*; import java.io.*; public class sqlProcedures { public static void main(String[] args) {…
Constructing a thread when you don’t know the class ahead of time
While building a generic load testing toolkit, I found it useful to be able to use a standard invocation framework for running a thread class that contains the actual application code to be stress tested. However, I had some problems…
Multiple threads using same physical connection
This just doesn’t sound good. Having multiple threads use the same physical connection sounds like an exercise in frustration. Although the OracleDataSource connection object is thread safe, there is really no need to create a smaller number of connections than…
Yet another reason to use Oracle’s JDBC connection manager
Over the weekend we had an odd issue. We have four nodes in a cluster, with two core services. SERVICE_A runs on servers 1 and 2, while SERVICE_B runs on server 4. Server 3 is effectively idle most of the…