How to use JDBC Bridge Options (System Property) for Java Commandline (e.g. classpath, proxy)

In this topic we will see how to set Java command line parameters using the options file in JDBC-ODBC Bridge Driver

Scenario

If you need to set a property for the java.exe command line, such as the one below, you can use the JdbcBridge.properties file mentioned in this article.

For example, if you want to pass some system-level property (indicated by the -D switch in java.exe), your command line may look like the one below in JAVA. In the next section, we will see how to achieve the same effect in the ZappySys JDBC Bridge Driver.

Example: Set System Property via Java Command Line
java.exe -Dsome_property1=some_value1 ....

Example: Set multiple System Properties via Java Command Line
java.exe -Dsome_property1=some_value1 -Dsome_property2=some_value2 ....

To achieve the same in Java code you might do something like below.

 System.setProperty("some-property-name1", "some-value1");
 System.setProperty("some-property-name2", "some-value2");
...

Setting System Properties in JdbcBridge.properties (Options file) for JAVA Command line

Let’s look at an example file for setting System Properties in JDBC Bridge Driver which yields the same result as previous command line we saw.

  1. Create a new file named JdbcBridge.properties at C:\Program Files (x86)\ZappySys\ZappySys ODBC PowerPack (Assuming you installed ZappySys ODBC PowerPack at default location)
  2. Paste the following code in the file and save it.

This sample is to enable Web Proxy for JDBC Drivers accessed by ZappySys JDBC-ODBC Bridge Driver.

java.args= -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8888 -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888

Confirm if Custom Options are loaded by Java Command Line

Now, to confirm if your settings are applied on the Java command line, you can perform the following steps.

  1. Open Windows Task manager > Go to Details Tab > Right click on any column header > Choose Columns > Ensure “Command Line” is checked so you can see like below.

  2. Now Go back to JDBC Bridge Data Source UI

  3. Click Test connection.

  4. Go back to Task Manager quickly and review java.exe entry in Details Tab. If it shows all options as per your JdbcBridge.properties then its good. If it doesn’t show there means you need to kill java.exe instance and close / re-open any open ODBC UI as described at the end of this article and try to Test again.

Available Options

######################################################
##Sample settings file for ZappySys JDBC Bridge
######################################################
# 1. Create a new text file name it JdbcBridge.properties, copy settings listed below, use # to comment line or use blank lines for spacing
#    Format is prop_name=prop_value (do not use space before or after equal sign)
# 2. Copy your JdbcBridge.properties file and place in the installation directory (root) or any other individual driver folders where JdbcBridge.jar file is located. 
#    Example Paths:
#        C:\Program Files (x86)\ZappySys\ZappySys ODBC PowerPack
#    OR  C:\Program Files (x86)\ZappySys\ZappySys ODBC PowerPack\JdbcBridgeDriverX86
#    OR  C:\Program Files (x86)\ZappySys\ZappySys ODBC PowerPack\JdbcBridgeDriverX64
#    OR  C:\Program Files (x86)\ZappySys\ZappySys ODBC PowerPack\ZappySys.TdsServer.WindowsService

###Enable Additional log from java side like below
#app.logfile=c:/temp/JdbcBridge_log.txt

###Set custom Java runtime path rather than using default path like below (uncomment / change as per your need)
#java.path=c:\JAVA\JDK8\bin\
#java.path=c:\Program Files\Amazon Corretto\jdk1.8.0_382\bin

###Enable HTTP/HTTPS Proxy like below (e.g. Use Fiddler Proxy or other Web Proxy)
#java.args= -Djava.net.useSystemProxies=true 
#--OR--
#java.args= -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8888 -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888
#--OR--
#Tools like Fiddler (web proxy tool) will need some extra settings to trust self-signed certificate 
#https://azureossd.github.io/2017/04/26/capture-java-vm-traffic-using-fiddler/
#java.args= -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=8888 -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=8888 -Djavax.net.ssl.trustStore="c:\Program Files\Amazon Corretto\jdk1.8.0_382\bin\FiddlerKeystore" -Djavax.net.ssl.trustStorePassword=test123

Restart Java after changes

After you save this file, you might have to give it at least 1 minute, assuming no application is using JDBC Bridge Driver.

After one minute of idle time, JDBC Bridge terminates the Java instance, so the next time you access JDBC Bridge, it will read your options file.

To kill Java forcefully, you can go to Task Manager> Find java.exe Process and Kill it. If you have multiple Java.exe then choose the one that has the command line below