Home
Analytics
JDBC URL from tomcat command line properties?
scherpbier
<p>I'm trying to deploy the birt runtime on an AWS Elastic Beanstalk running Tomcat 8.</p>
<p>Using birt 4.4.2</p>
<p> </p>
<p>How can I construct the JDBC connection information from the properties that Elastic Beanstalk puts into the tomcat command line?</p>
<p> </p>
<p>I cannot put these as constants in the report because 1) I can't have my report designer use the same URL, and 2) there are multiple beanstalks in various environments and places around the world that the war is deployed to, and each environment has its own JDBC host/username/password</p>
<p> </p>
<p>For the Java code in the war file, I simply use System.getProperty() to retrieve the various properties that make up the JDBC URL. (RDS_HOSTNAME, RDS_PORT, RDS_DB_NAME, RDS_USERNAME, and RDS_PASSWORD are the properties that are provided)</p>
<p> </p>
<p>Ideally, I would like to have the JDBC URL created using some Java code so I can easily make it work in both production, testing and development.</p>
<p> </p>
<p>Any suggestions?</p>
Find more posts tagged with
Comments
JFreeman
<p>You could create a java class that gets and returns the connection information when called. Then add that class to your reports resources.</p>
<p>
Then in the data source, within the Property Binding, you can override the JDBC Driver URL, User Name, Password, etc. by calling the class with some javascript.</p>
scherpbier
<p>Thank you, Jesse! That's exactly what I was looking for.</p>
<p> </p>
<p>I was actually able to do this without creating a Java class simply by calling</p>
<pre class="_prettyXprint _lang-js">
Packages.java.lang.System.getProperty("RDS_USERNAME", "testuser");
</pre>
<p>in the property binding for the data source.</p>
JFreeman
<p>You're welcome.</p>
<p>I'm glad that did the trick for you.</p>
<p>Let us know if you have additional questions.</p>