Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

JDBC Invalid column index: getValidColumnIndex Error

By: a guest on Oct 8th, 2012  |  syntax: Java  |  size: 0.76 KB  |  views: 64  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1.                 public static void main(String[] args) throws SQLException
  2.                 {
  3.                         DBConnection dbc = new DBConnection(); // generate the connection string and object
  4.                         Connection conn = dbc.getDBConnection(); // get the connection object
  5.                         //interact with the database
  6.                         Statement statement = conn.createStatement();
  7.                         ResultSet resultSet = null; // get the result of the query to the database
  8.                        
  9.                         resultSet = statement.executeQuery(Suppliers.selectSuppliersTableString);
  10.                         System.out.println(Suppliers.columnHeadersString);
  11.         //              ResultPrinter.resultPrinter(resultSet);
  12.                         ResultSetMetaData rsmd = resultSet.getMetaData();
  13.                         int columnCount = rsmd.getColumnCount();
  14.                         System.out.println("Columns: " + columnCount);
  15.                         System.out.println(rsmd.getColumnName(0));
  16.                 }