Advertisement
Guest User

JDBC Invalid column index: getValidColumnIndex Error

a guest
Oct 8th, 2012
505
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  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.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement