Ifraz Imanudeen wrote:
Below is the OUPUT ERROR for above;
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
All things are lawful, but not all things are profitable.
Ron McLeod wrote:I don't have a complete answer, but here are some issues that I can see:
- For INSTOCK and OUTSTOCK, you probably want COUNT() rather than SUM()
- StockStatus is an INTEGER, but you are trying to match to 'IN' and 'OUT'
- Missing ON in JOIN statement
- Its GROUP BY not GROUPBY
- You are referencing a placeholder in your PreparedStatement (PIN.setString(1, ...)), but there is no placeholder defined
- I don't think you can SUM two aliases as you have specified. Why not just calculate INSTOCK - OUTSTOCK in your code?
Tim Holloway wrote:Something important to note is that it is very dangerous to use upper/lower case in SQL database table and column names. Not all SQL DBMS's handle mixed case the same way and some have very strange ways of dealing with mixed case.
In SQLite, I believe that mixed case is handled literally, so you have to use the exact same case usage all the time, and thus, for example, OUTSTOCK would not match OutStock. What I recommend actually would be out_stock as the safest name, but lots of SqlLite projects do use mixed case.
And ORDER BY is 2 words. ORDERBY is invalid.
Knute Snortum wrote:Also GROUPBY is GROUP BY (which is what I think Tim meant).
Paul Clapham wrote:That code from line 14 to 21: you execute it before the first row of the ResultSet has been read, so it should throw an exception. However at lines 29 and 30 you have code which runs regardless of whether an exception was thrown, in effect ignoring the exception. I don't think you should be doing that, unless it's really true that it doesn't matter to 29 and 30 whether the SQL was processed correctly or not.
And in line 24 you create a new TableModel for each row of the ResultSet and add it to... something. Not sure what the something is but I suspect that you maybe should have only one TableModel.
Paul Clapham wrote:Well, like I said already, you're doing that calculation of IN and OUT and Res before you start looping through the ResultSet. I'm surprised that doesn't throw an exception but at any rate since you only do that calculation once, you can't expect to see different values for it in your output.
Paul Clapham wrote:Well, like I said already, you're doing that calculation of IN and OUT and Res before you start looping through the ResultSet. I'm surprised that doesn't throw an exception but at any rate since you only do that calculation once, you can't expect to see different values for it in your output.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.
Ifraz Imanudeen wrote:Will it Solve my problem, if i have Two columns in the Table for IN and OUT instead of doing the SUM with the StockStatus.
Ron McLeod
Paul Clapham
Tim Holloway
Knute Snortum