Why wont my vector work?

icklejez

Member
Jan 12, 2007
50
0
0
I try to pass some SQL data to my vector, then display it, but it says the data cannot be retrieved even though when i delete the vector elementadd parts, it works fine...

jdbcConnect();
ResultSet results = null;
Vector stocklist = new Vector();

try
{
statement = link.createStatement();
results = statement.executeQuery(
"SELECT * FROM StockAccess");
while (results.next())
{


System.out.println("Stock Code: " + results.getString(1));
System.out.println("Stock Description: " + results.getString(2) + " ");
System.out.println("Stock Quantity: " + results.getInt(3));
System.out.println("Stock ReOrder Level: " + results.getInt(4));
System.out.println("Price: " + results.getFloat(5));
System.out.println();

stocklist.addElement(results.getString(1));
stocklist.add(results.getString(2));
stocklist.add(results.getInt(3));
stocklist.add(results.getInt(4));
stocklist.add(results.getFloat(5));

System.out.println(stocklist);
}

}
catch(SQLException e)
{
System.out.println("* Error retrieving data! *");
e.printStackTrace();
System.exit(1);
}
closeDown();
}

Anyone got any idea why my vector doesnt work?