try { Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" ); } catch( ClassNotFoundException event ) { System.out.println ( "Fehler bei ODBC-JDBC Treiber Initialisierung" + event ); return; } Connection con02 = null; Statement stmt02; String url02 = "jdbc:odbc:Datenbank"; ResultSet rSet02 = null; String sqlQuery02 = "SELECT * FROM Film;"; try { con02 = DriverManager.getConnection( url02,"User","Password" ); stmt02 = con02.createStatement(); rSet02 = stmt01.executeQuery( sqlQuery02 ); ResultSetMetaData metadata = rSet02.getMetaData(); rows = new Vector(); while( rSet02.next() ) { Vector newrow = new Vector(); for(int a = 1; a <= metadata.getColumnCount(); a++) { newrow.addElement(rSet02.getObject(i)); } rows.addElement(newrow); } stmt02.close(); Vector spalten = new Vector(); //int numberOfColumns = metadata.getColumnCount(); //for (int column = 0; column < numberOfColumns; column++) //{ // columnNames.addElement(metaData.getColumnLabel(column + 1)); //} spalten.addElement("ID"); spalten.addElement("NAME"); spalten.addElement("DAUER"); spalten.addElement("ALTER"); model = new DefaultTableModel(spalten, rows) { public boolean isCellEditable(int row, int col) { return false; } }; table = new JTable(); table.setBounds(30,105,540,150); table.setRowHeight(20); table.setRowMargin(0); table.setShowHorizontalLines(true); table.setShowVerticalLines(true); table.setGridColor(Color.black); table.setSelectionForeground(Color.white); table.setRowSelectionAllowed(true); table.setColumnSelectionAllowed(false); table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); table.addMouseListener(new Mausklasse()); table.setModel(model); ziehen = new JScrollPane(table); ziehen.setBounds(30,105,540,150); //int hpolicy = ziehen.getHorizontalScrollBarPolicy(); //int vpolicy = ziehen.getVerticalScrollBarPolicy(); ziehen.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); ziehen.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); panel.add(ziehen); } catch( SQLException event) { System.out.println( "Fehler bei Tabellenabfrage " + event); return; } finally { try { if ( con02 != null ) { con02.close(); } } catch ( SQLException event ) {} }