Jdbcrowset bug ? return nullpointer exception!

package CrimeFile;

import com.sun.rowset.JdbcRowSetImpl;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.sql.rowset.JdbcRowSet;

 * @author singgum3b
public class test {

     * @param args the command line arguments
    public static void main(String[] args) {
        try {
            // TODO code application logic here
                    JdbcRowSet jrsi=new JdbcRowSetImpl();
                    jrsi.setCommand("select * from dbo.Target");
        catch (SQLException ex) {            
            Logger.getLogger(test.class.getName()).log(Level.ALL, null, ex);


Exception in thread "main" java.lang.NullPointerException
    at com.sun.rowset.JdbcRowSetImpl.prepare(JdbcRowSetImpl.java:666)
    at com.sun.rowset.JdbcRowSetImpl.execute(JdbcRowSetImpl.java:553)
    at CrimeFile.test.main(test.java:30)
Java Result: 1

(line 30 is crsi.excute();)

I’m using sql server 2008 and ms jdbc 3.0.I googling around and found out this code is the same as in Sun’s example link .Am i wrong?

  • Group by is throwing error in SQL Server
  • Pivot a fixed multiple column table in sql server
  • Sync with active table Microsoft SQL Server
  • Is there a tool to generate a full database DDL for SQL Server? What about Postgres and MySQL?
  • SQL Server Pre-Login Handshake Acknowledgement Error
  • Troubleshooting SQL Server connection issues
  • Return an array after querying database in Java
  • java delete column from primary key that start with?
  • Connecting SQL Server 2008 to Java: Login failed for user error
  • Running composite query on SQL server 2014 does not return result set
  • Connection JDBC SQL Server Error
  • sqlserver express connection over servername\instancename
  • 3 Solutions collect form web for “Jdbcrowset bug ? return nullpointer exception!”

    Ok, the answer was to switch to JtDS driver, which can be found here

    There’s clearly something bollixed up in MS JDBC driver.

    I was having the same problem and came to conclusion that the problem is that Microsoft driver doesnt support combination of conn.prepareStatemen(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE); as stated
    at microsoft website
    resulting in exception of prepare() method.
    I took source code from here created my own MyJdbcRowSetImpl and changed parameter of prepareStatement to ResultSet.TYPE_SCROLL_SENSITIVE

    Jtds driver wasnt solution as it doesnt support rowsets.

    I remember this NullPointerException happening to me but only if I call execute() when I should NOT be doing so i.e. when using JdbcRowSetImpl with a ResultSet as argument

    private JdbcRowSet executeWithResultSet(Connection conn, String sqlQuery)
            throws SQLException {
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(sqlQuery);
        JdbcRowSet jdbcRs = new JdbcRowSetImpl(rs);
        jdbcRs.execute(); //<-- results to the error as reported
        return jdbcRs;
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.