Reputation: 11
I am trying to get some information out of my database from Java.
String sql_get_Tot = "
SELECT
dbo.table1.Quantity * dbo.table2.CostPerIndivdual AS QC
FROM
dbo.table1
INNER JOIN
dbo.table2
ON dbo._IISJoin.ItemID = dbo.table2.ItemID
WHERE
dbo.table1.SupplierID = 2 AND
dbo.table1.ItemID = 1 AND
dbo.table1.InvoiceID = 2
";
state = con.createStatement();
total = state.executeQuery(sql_get_Tot);
totalsql = total.getFloat(1);
This Returns nothing within the result set
Run Exactly the same query in MSSQL and I get 10.00
any ideas what is going wrong here, I have checked the basics such as connected to the right database and so on.
Thanks for any help you might be able to provide in advance.
Upvotes: 1
Views: 69
Reputation: 7764
I believe that "total" is a ResultSet. So then you need to do a:
if(total.next()){
totalsql = total.getFloat(1);
...
Upvotes: 1