public List<String> getDBTable(String tableName) { List<String> columns = new ArrayList<String>(); String driver = "com.mysql.jdbc.Driver"; String url = "jdbc:mysql://127.0.0.1:3306/sshdb"; try { Class.forName(driver); Connection conn = DriverManager.getConnection(url, "root", ""); Statement stm = conn.createStatement(); ResultSet rs = stm.executeQuery("show columns from " + tableName); while(rs.next()) { columns.add(rs.getString("Field")); } rs.close(); stm.close(); conn.close(); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return columns; }