I am getting a memory issue when I run the following query in my Java program with Progress DataDirect MongoDB JDBC driver with a large table in a database (40 million records):

```
String query = "SELECT * FROM (SELECT tablename.*, ROW_NUMBER() OVER() AS rowid FROM tablename)";

```

The query above works perfectly fine if I have a small table in the database.

If I just run "SELECT ROW\_NUMBER() OVER() AS rowid FROM tablename", then the name of the column will become null. The AS seems not effect in the statement:

> 
> Column Name: null class java.lang.Integer
> 
> 
> Exception in thread "main" java.lang.NullPointerException
> 
> 
> 

If I just run "SELECT \* FROM tablename", it is very fast to get the ResultSet object back and I can easily read the 40 million records in less than few minutes.

So what am I missing? I don't know how to use the ROW\_NUMBER function correctly. Any idea? Thanks.