Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Answer to your question:<br/> No, is not possible because (from PreparedStatement javadoc)</p> <p><a href="http://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html#executeQuery%28%29" rel="nofollow">ResultSet executeQuery() throws SQLException</a></p> <blockquote> <p>Executes the SQL query in this PreparedStatement object and returns the ResultSet object generated by the query.</p> </blockquote> <p>and you can't change this signature.</p> <p>Your intention is to return the whole <code>ResultSet</code> in <code>Array&lt;&gt;[]</code> variable and, for large resultset, this can results in a <code>OutOfMemoryException</code>.<br/> You can think to use Spring JDBC support and <a href="http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/jdbc/core/JdbcTemplate.html#queryForList%28java.lang.String,%20java.lang.Class%29" rel="nofollow" title="JDBCTemplate.queryForList&#40;&#41;">JDBCTemplate.queryForList()</a> to make use of <code>ResultSet</code> mapping easy</p> <p>EDIT:<br/> About your code best choice is to change query as:</p> <pre><code>select Col3,MyOption from MyOption where OptionKey in (?,?,?,?) and ID = " + _Id"; while(rs.hasNext()) { String option = rs.getString(2); String optionValue = rs.getString(1); String propertyName = null; if(option.contains("imap")) { switch(options) { case "Mail.IMAP.Server": propertyName = "mail.imap.host"; break; case "Mail.IMAP.Port": propertyName = "mail.imap.port"; break; case "Mail.IMAP.AuthUser": propertyName = "mail.imap.auth"; break; case "Mail.IMAP.UseTLS": propertyName = "mail.imap.starttls.enable"; break; } if(null != propertyName) { properties.setProperty(propertyName, optionValue); } } } </code></pre>
 

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