I am writing a program to provide stock data to a GUI, which will update real time. When I use the Smart Tags in Excel, it updates with 13 columns: Last
, Previous
, Close
, High
, Low
, Volume
, Change
, % Change
, 52 Wk High
, 52 Wk Low
, Market Cap
, EPS
, P/E Ratio
, and # Shares Out
. However, I only want to deal with a few of the columns. Is there any way to only select a few of the columns to pull the data from? This is what I am using to pull the data and it works, but I don't want all of it:
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection connect = DriverManager.getConnection("jdbc:odbc:Book1");
Statement st = connect.createStatement();
ResultSet result_set = st.executeQuery("SELECT * FROM A3:P30");
ResultSetMetaData md = result_set.getMetaData();
int columns = md.getColumnCount();
for (int i = 1; i <= columns; i++) {
columnNames.addElement(md.getColumnName(i));
}
while (result_set.next()) {
Vector row = new Vector(columns);
for (int i = 1; i <= columns; i++)
row.addElement(result_set.getObject(i));
data.addElement(row);
}
result_set.close();
st.close();
} catch (Exception e) {
System.out.println(e);
}
In Book1
, I have 27 entries which is where P30
comes from..
Thank you, in advance!