Note that there are some explanatory texts on larger screens.

plurals
  1. POJava JDBC Connection Pooling (How to check)?
    primarykey
    data
    text
    <p>First of all, I'm new to <code>Java/JSP/Eclipse</code>. However, I've many many years of .Net experience. I have just learned in Java how to make a connection to MS SQL Server using the <code>javax.sql.DataSource</code> (so that I don't need to key in the userid/password).</p> <p>Right now, I've created a class to handle DB query, and in that class, I have a function that I can just call to return a <code>RowSet</code>.</p> <pre><code> import javax.naming.Context; import javax.naming.InitialContext; import java.sql.Connection; import javax.sql.DataSource; import javax.sql.rowset.JdbcRowSet; import com.sun.rowset.JdbcRowSetImpl; public abstract class ClsDBAccessBASE { public boolean prbAutoCommit = true; public String prsDataSourceName = ""; public ClsDBAccessBASE( String pvsDataSourceName ) { prsDataSourceName = pvsDataSourceName; } public JdbcRowSet fnorsSQLText( String pvsSQLText ) { JdbcRowSet voRS = null; try { Context voContext = new InitialContext(); DataSource voDS = (DataSource)voContext.lookup(prsDataSourceName); Connection voConn = (Connection)voDS.getConnection(); voRS = new JdbcRowSetImpl((voConn.createStatement()).executeQuery(pvsSQLText)); } catch (Exception e) {e.printStackTrace();} return voRS; } } } </code></pre> <p>My objective is to ensure that I am using Connection Pooling. I understand that the <code>JdbcRowSet</code> implements that automatically? However, the problem (I think) is that I am casting the <code>(voConn.createStatement()).executeQuery(pvsSQLText)</code> from a <code>ResultSet</code> to a <code>JdbcRowSet</code>. Would this mean that the underlying connection used is still <code>ResultSet</code>? and not <code>RowSet</code>? Is there a way for me to check that I am indeed using Connection Pooling?</p> <p>I'm sorry, if my question sounds silly. I am very new to Java development &amp; Eclipse. Please bear with me and I will appreciate any guidance you can provide me.</p> <p>I am using: <code>sqljdbc4.jar</code> from <code>Microsoft</code> (which seems to give me error whenever I call the <code>JdbcRowSet.execute()</code> function and/or .next() function. Something about NullReference. But that's another problem.</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.
 

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