Tagged java on Rasmus.krats.sehttps://rasmus.krats.se/tag/java.en2017-06-24T12:00:00+00:00Reminiscing this and that, on the web since 1994.Logdriverhttps://rasmus.krats.se/2009/logdriver.en2017-06-24T12:00:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2009-06-03T18:10:00+00:00<p>When developing code with Hibernate (or other Java tools that create
SQL statements for you) it is often a good idea to take a close look
at the generated SQL code, for example if you have performerance
issues.</p>
<p>A very nice and simple way to do that is logdriver by
Ryan Bloom.
(Update 2017-06-24: Unfortunatley, the domain seems to have been lost
to a spam site).</p>
<p>And it’s simple to use! I’ve got a <code>.properties</code> file where I’ve
commented out the ordinary db driver and use logdriver instead. As
simple as this:</p>
<pre data-lang="properties"><span class="syhsource syhjava-props"><span class="syhcomment syhline syhnumber-sign syhjava-props"><span class="syhpunctuation syhdefinition syhcomment syhjava-props">#</span> DB_DRIVER=oracle.jdbc.driver.OracleDriver
</span><span class="syhcomment syhline syhnumber-sign syhjava-props"><span class="syhpunctuation syhdefinition syhcomment syhjava-props">#</span> DB_URL=jdbc:oracle:thin:@dbhost.mydomain:1523:db
</span><span class="syhkeyword syhother syhjava-props">DB_DRIVER</span><span class="syhpunctuation syhseparator syhkey-value syhjava-props">=</span>net.rkbloom.logdriver.LogDriver
<span class="syhkeyword syhother syhjava-props">DB_URL</span><span class="syhpunctuation syhseparator syhkey-value syhjava-props">=</span>jdbc:log:oracle.jdbc.driver.OracleDriver:oracle:thin:@dbhost.mydomain:1523:db
</span></pre>
<p class='readmore'><a href='https://rasmus.krats.se/2009/logdriver.en'>Be the first to comment.</a></p>Destruktorer och deferhttps://rasmus.krats.se/2014/go-defer.sv2014-11-09T00:10:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2014-11-09T00:10:00+00:00<p>En av de saker jag verkligen gillar i c++ är att man kan ha lokala
variabler som är objekt i kombination med att objekt har destruktorer.
När man lämnar ett scope där det finns lokala variabler kommer deras
destruktorer omedelbart att köras, oavsett hur man lämnar scopet.
Det ger ett trevligt sätt att hantera öppna filer, databaskoppel,
mutexar och annat som behöver stängas. Andra språk har andra, ofta
krångligare, sätt att få motsvarande resultat.</p>
<p>Språket <em>go</em> har en helt annan aproach, som är värd att titta lite
närmare på.</p>
<p class='readmore'><a href='https://rasmus.krats.se/2014/go-defer.sv'>Läs hela <q>Destruktorer och defer</q> med 3 kommentarer.</a></p>Some ways to log stuff in javahttps://rasmus.krats.se/2013/loggers.en2013-11-14T15:10:00+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2013-11-14T15:10:00+00:00<p>Logging in java is a mess.
For a long time there was no standard way of logging in java, so there
is a lot of 3:rd party solutions.
Apache commons logging, slf4j, and log4j are probably the most used.</p>
<p>By now, there is standard <code>java.util.logging</code> package, but most people
stick to the old 3:rd party solutions.
As we shall see, that isn’t really surprising, since java util logging
kind of sucks.</p>
<p>I have done some exploration of different options for logging in java.</p>
<p class='readmore'><a href='https://rasmus.krats.se/2013/loggers.en'>Read whole <q>Some ways to log stuff in java</q>.</a></p>Black Boxhttps://rasmus.krats.se/2000/blackbox.en2000-07-03T22:58:49+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj2000-07-03T22:58:49+00:00<p>Welcome to this simple mind game.</p>
<p class='readmore'><a href='https://rasmus.krats.se/2000/blackbox.en'>Read whole <q>Black Box</q>.</a></p>Java game of fifteen tileshttps://rasmus.krats.se/1998/15.en1998-07-25T22:43:54+00:00Rasmus Kajhttps://rasmus.krats.se/rkaj1998-07-25T22:43:54+00:00<p>This is the classical game of fifteen tiles in Java. If
you’ve seen a real one it shouldn’t be too hard to figure it
out …</p>
<p class='readmore'><a href='https://rasmus.krats.se/1998/15.en'>Read whole <q>Java game of fifteen tiles</q>.</a></p>