null pointer exception in select query
843854Feb 4 2003 — edited Feb 4 2003hello
i am getting null pointer exception in the following code. i m using Ms Access database
-----
-----
----
------
for(int i = o ; i < 12;i++)
{
Vector show = displaymonthdata(orderid);
}
---
----
-----
public Vector displayMonthwisedata(String newid[])
{
Vector toadd = new Vector();
Vector ship = new Vector();
Vector contract =new Vector();
int consize = 0;
if(newid.length > 0)
{
for(int i = 0 ; i < newid.length ; i++)
{
contract = selectShipfrmcontract(newid);
if((contract!=null)
{
System.out.println("not null");
consize = contract.size();
System.out.println("contractsize: "+contract.size());
if(consize > 0 )
{
ship.add(ship.size(),contract);
}
consize = 0;
}
}
}
---
----
--
}//displaymonthwisedata
public Vector selectShipfrmcontract(String orderid)
{
Vector members = null;
System.out.println("orderid in query: "+orderid);
try
{
DBConnect dbconn = new DBConnect();//library class used by us for connection n query results
dbconn.connectToDb();//for connection
String sql = "select * from shipment_details where sale_contract_id in"
+"(select sales_contract_id from sales_contract where order_id="
Integer.parseInt(orderid.trim())")";
System.out.println("ship query: "+sql);
members = dbconn.exeQuery(sql);//returns empty vector if there r no records for perticular vector.
}
catch (Exception e)
{
System.out.println(" ERROR IN EXECUTING QUERY in selectshipfrmcontract: "+e);
return null;
}
return members;
}
The above code is used to search annual sales for perticular item.it runs fine for first 8 values of for loop,
After that it gives null pointer exception at following line
consize = contract.size();
plz help.