Note that there are some explanatory texts on larger screens.

plurals
  1. POCan JDBCConnectionManager be used with JDBCRowSet?
    primarykey
    data
    text
    <p>I am trying to use <code>&lt;xe:jdbcConnectionManager&gt;</code> with <code>&lt;xe:jdbcRowSet&gt;</code>. Should this work? The book (XPages Extension Library) seems to imply it should, but the example NSF (XPagesJDBC.nsf) does not contain any examples with that combination. Of course, the jdbcRowSet accepts <code>connectionManager</code> attribute.</p> <p>I get this error:</p> <pre><code>com.ibm.xsp.FacesExceptionEx: Unknown ConnectionManager jdbcConnectionManager1 com.ibm.xsp.extlib.util.JdbcUtil.createManagedConnection(JdbcUtil.java:106) com.ibm.xsp.extlib.jdbc.model.JdbcRowSetAccessor.findConnection(JdbcRowSetAccessor.java:467) </code></pre> <h2>EXTLIB CODE</h2> <p>The problem seems to be in JdbcUtil.java function findConnectionManager(). It returns null and that's why I get the above exception. Here's the function:</p> <pre><code>public static IJdbcConnectionManager findConnectionManager(FacesContext context, UIComponent from, String name) throws SQLException { UIComponent c = FacesUtil.getComponentFor(from, name); if(c!=null) { return (IJdbcConnectionManager)c; } return null; } </code></pre> <p>The parameter <code>name</code> is not null since it is referenced in the exception message. The parameter <code>context</code>is not used at all. And the parameter <code>from</code>, if null, is acquired like this (on row 102): <code>from = context.getViewRoot();</code>.</p> <p>Here's the function throwing the exception:</p> <pre><code>public static Connection createManagedConnection(FacesContext context, UIComponent from, String name) throws SQLException { if(from==null) { from = context.getViewRoot(); // ROW 102 } IJdbcConnectionManager manager = findConnectionManager(context, from, name); if(manager==null) { throw new FacesExceptionEx(null,"Unknown ConnectionManager {0}",name); // ROW 106 } return manager.getConnection(); } </code></pre> <h2>MY CODE</h2> <p>So, this works:</p> <pre><code>&lt;xp:this.data&gt; &lt;xe:jdbcRowSet var="jdbcRowSet1" maxRows="10" sqlQuery="SELECT * FROM test.reportcode;" connectionName="mysql_pooled"&gt; &lt;/xe:jdbcRowSet&gt; &lt;/xp:this.data&gt; </code></pre> <p>And this doesn't work:</p> <pre><code>&lt;xe:jdbcConnectionManager id="jdbcConnectionManager1" connectionName="mysql_pooled"&gt; &lt;/xe:jdbcConnectionManager&gt; &lt;xp:this.data&gt; &lt;xe:jdbcRowSet var="jdbcRowSet1" maxRows="10" sqlQuery="SELECT * FROM test.reportcode;" connectionManager="jdbcConnectionManager1"&gt; &lt;/xe:jdbcRowSet&gt; &lt;/xp:this.data&gt; </code></pre> <p>Note that the connectionName is identical, and works perfectly when used directly by jdbcRowSet. The only change is replacing that attribute with a reference to jdbcConnectionManager using that same connectionName. The setup works also perfectly with the jdbcQuery datasource.</p> <p>How can I make this work? Or can it be done?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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