Search code examples
javasqloracle-databasejdbcresultset

ResultSet.next always false, table populated


My table:

create table ranking (rennId int not null, fId int not null, pos int not null, CONSTRAINT key PRIMARY KEY (rennId,fId))

My java code:

try {
    Connection con = DriverManager.getConnection(url, user, password);
    ResultSet ret = con.createStatement().executeQuery("select * from ranking");
    while (ret.next())
        System.out.println("test");
} catch (SQLException e) { e.printStackTrace(); }   

Manual test:

sql> select * from ranking
[2017-06-13 03:21:59] 3 rows retrieved starting from 1 in 52ms (execution: 45ms, fetching: 7ms)

Tested as standalone
Only occurs on this table


Solution

  • Apparently it was an issue combined with DataGrip. This code actualy selects all entries created within this application, but ignores all entries created via DataGrip. Seems to be related to a combined Primary Key