Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I've made the following (rough) tests just to illustrate the cost of raising an exception vs checking if columns exist in the RecordSet, in my particular case.</p> <p>The number of columns to check was 169.</p> <p>Code 1</p> <pre><code>try { sTemp = this.rsResults.getString("col3"); }catch(Exception e){} try { sTemp = this.rsResults.getString("col4"); }catch(Exception e){} ... try { sTemp = this.rsResults.getString("col169"); }catch(Exception e){} </code></pre> <p>Code 2 with function hasColumn [question]:<a href="https://stackoverflow.com/questions/3599861/how-can-i-determine-if-the-column-name-exist-in-the-resultset">How can I determine if the column name exist in the ResultSet?</a></p> <pre><code>ResultSetMetaData rsmd = null; try { rsmd = this.rsResults.getMetaData(); } catch (SQLException e1) { e1.printStackTrace(); } try{ if (rsmd != null &amp;&amp; hasColumn(rsmd,"col3")) sTemp = this.rsResults.getString("col3"); }catch(Exception e){} try{ if (rsmd != null &amp;&amp; hasColumn(rsmd,"col4")) sTemp = this.rsResults.getString("col4"); }catch(Exception e){} ... try{ if (rsmd != null &amp;&amp; hasColumn(rsmd,"col169")) sTemp = this.rsResults.getString("col169"); }catch(Exception e){} </code></pre> <p>Results without c3p0</p> <pre><code> code 1 code 2 query nº1 75ms 36ms query nº2 40ms 43ms query nº3 227ms 46ms query nº4 262ms 18ms </code></pre> <p>Results with c3p0 loglevel at INFO</p> <pre><code> code 1 code 2 query nº1 519ms 45ms query nº2 358ms 28ms query nº3 2348ms 9ms query nº4 3243ms 12ms </code></pre> <p>As a conclusion the cost of raising an exception just to check if columns exists (besides of being bad practice) is high in both cases and especially if using c3p0.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload