Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #35419
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Steven Simpson <ss@my.domain.invalid> |
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Logging database statement duration in a DRY way |
| Date | Fri, 19 Aug 2016 22:34:31 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 16 |
| Message-ID | <7kak8d-rai.ln1@s.simpson148.btinternet.com> (permalink) |
| References | <87wpjdhrbm.fsf@Equus.decebal.nl> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=windows-1252; format=flowed |
| Content-Transfer-Encoding | 7bit |
| Injection-Info | mx02.eternal-september.org; posting-host="aeef5e178076fda4998e4379bb1adbab"; logging-data="7408"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18nFlJAVmb3sKJoS+fNwU16zi03uWiXmZ4=" |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
| In-Reply-To | <87wpjdhrbm.fsf@Equus.decebal.nl> |
| Cancel-Lock | sha1:5OMWEk8F+fXNHnyvUc76pbrSdd4= |
| Xref | csiph.com comp.lang.java.programmer:35419 |
Show key headers only | View raw
On 19/08/16 13:32, Cecil Westerhof wrote:
> This works, but I need to copy the first and last two statements and
> edit the last one, so I was wondering if this could be done more DRY
> (Do not Repeat Yourself). In C(++) you would use a macro, but as far
> as I know this is not possible with Java.
You could create a class implementing AutoCloseable:
try (MyTimer t = new MyTimer(logger, "preparedStatement saveMemoryLineNoGC")) {
...
}
--
ss at comp dot lancs dot ac dot uk
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
Logging database statement duration in a DRY way Cecil Westerhof <Cecil@decebal.nl> - 2016-08-19 14:32 +0200
Re: Logging database statement duration in a DRY way Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-19 09:05 -0400
Re: Logging database statement duration in a DRY way Cecil Westerhof <Cecil@decebal.nl> - 2016-08-19 20:54 +0200
Re: Logging database statement duration in a DRY way Cecil Westerhof <Cecil@decebal.nl> - 2016-08-19 15:12 +0200
Re: Logging database statement duration in a DRY way Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-08-19 10:01 -0400
Re: Logging database statement duration in a DRY way Arne Vajhøj <arne@vajhoej.dk> - 2016-08-19 22:17 -0400
Re: Logging database statement duration in a DRY way Arne Vajhøj <arne@vajhoej.dk> - 2016-08-19 22:37 -0400
Re: Logging database statement duration in a DRY way Martin Gregorie <martin@address-in-sig.invalid> - 2016-08-19 16:05 +0000
Re: Logging database statement duration in a DRY way Eric Douglas <e.d.programmer@gmail.com> - 2016-08-19 10:06 -0700
Re: Logging database statement duration in a DRY way Steven Simpson <ss@my.domain.invalid> - 2016-08-19 22:34 +0100
csiph-web