I have a SQL Lite database, containing specific values i need to count. I need only once that are related to a certain value. If I write the following request in database :
SELECT count(Global_Sales) FROM Data WHERE Platform =='PC';
I get what I need. However if I use the same request in my function, all of the requests I keep in a txt file, it says this:
no such column: 'count'
The code that I use:
try(Connection conn = DriverManager.getConnection(url))
{
Path pathRQ = Paths.get("resources/BaseRequests.txt");
requests = Files.readAllLines(pathRQ, StandardCharsets.UTF_8);
Statement stm = conn.createStatement();
for(int i =0; i < requests.size();i++)
{
Value.add(stm.executeQuery(requests.get(i)).getInt("count"));
}
}
catch(SQLException ex )
{
System.out.println(ex.getMessage());
}
catch(IOException ex )
{
System.out.println(ex.getMessage());
}
I've tried to change "count" to "Global_Sales" - the same message appears just with a bit different text. I don't know why it happens,maybe that's because all the values in data base are kept as "TEXT" or maybe that's because I've did something wrong in my code here. Question is - How do i fix this?