-3

Executing javac JdbcRowSet.java on the following excerpt confuses me:

//
import javax.sql.*;
import javax.sql.rowset.*;
import java.sql.*;

class JdbcRowSet
{
    public static void main(String ... args){
        StringBuilder sb = new StringBuilder();

        try(JdbcRowSet jrs = RowSetProvider.newFactory().createJdbcRowSet()){
            //CODE
}
//

According to JavaDoc:

public interface ResultSet extends Wrapper, AutoCloseable

public interface RowSet extends ResultSet

public interface JdbcRowSet extends RowSet, Joinable

I got the following errors:

dbcRowSet.java:8:error: incompatible types: javax.sql.rowset.JdbcRowSet cannot be converted to JdbcRowSet try(//)
JdbcRowSet.java:8:error: incompatible types: try-with-resources not applicable to variable type
JdbcRowSet cannot be converted to AutoCloseable.

The errors are strangely confusing. Can someone help me on this. Thank you.

1m9K
  • 3
  • 1
  • 8

1 Answers1

1

As @Kayaman correctly pointed out in his comment - you are declaring your own JdbcRowSet class.

Either change the name of the class or fully qualify the object in the try.

try(javax.sql.rowset.JdbcRowSet jrs = RowSetProvider.newFactory().createJdbcRowSet())
OldCurmudgeon
  • 64,482
  • 16
  • 119
  • 213
  • thanks OldCurmudgeon. i appreciated your help. ISelf study purpose only and no claim of any kind of proficiency. – 1m9K Feb 07 '18 at 18:38