JDBC selecting the Max value from an Access table

前端 未结 2 793
忘掉有多难
忘掉有多难 2021-01-23 05:12

I got error \"Column not found\" any time i run the following code even though the column exist in my table. Am using access database, Appealing for help please

         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-23 05:34

    Assuming the error is when you get the result rather than when you execute the query, you probably need something like this instead

    // ...
    ResultSet rs = stmt.executeQuery("select MAX(LevelNum) as maxLevel from NList");
    if (rs.next())
    {
        int w = rs.getInt("maxLevel");
    
        // ... etc.
    }
    

提交回复
热议问题