Skip to content

Instantly share code, notes, and snippets.

@wytten
Created April 16, 2021 15:45
Show Gist options
  • Save wytten/c2d43d6d4f5927faeaf577a888065391 to your computer and use it in GitHub Desktop.
Save wytten/c2d43d6d4f5927faeaf577a888065391 to your computer and use it in GitHub Desktop.
Transform JDBC URL's into proxy URL's for use with jnettrace.jar
#!/usr/bin/perl
use feature qw(say);
# This script can be used to transform JDBC URL's into proxy URL's for use with jnettrace.jar,
# and is based on Oracle support article:
# How to Perform the Equivalent of SQL*Net Client Tracing with Oracle JDBC Thin Driver (Doc ID 793415.1)
# For an alternative tracing approach based on java.util.logging, see:
# How to Trace the Network Packets Exchanged Between JDBC and the RDBMS (Doc ID 1050942.1)
$num_args = $#ARGV + 1;
if ($num_args != 3) {
say "Args required: host port\n";
exit;
}
$host = shift @ARGV;
$port = shift @ARGV;
while(<>) {
if ( /(.*url)=jdbc.*:[0-9]+\/(.*)/ ) {
printf "%s=jdbc:oracle:thin:@%s:%s/%s\n", $1, $host, $port, $2;
} else {
print;
}
}
# Linux:~/properties% jnettrace.pl localhost 123 environment.properties > environment-jnettrace.properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment