вот мой код, он не работает, потому что показывает пустую таблицу без строк и столбцов
Может кто-то тел, где проблема
public class test extends JFrame {
private final JButton pridetiNaujaButton = new JButton();
private final JButton pasalintiButton = new JButton();
private final JButton redagotiButton = new JButton();
private final JButton paieskaButton = new JButton();
final GtFromDb baz=new GtFromDb();
private Vector <Vector<String>> data;
private Vector<String> header;
private final JScrollPane scrollPane = new JScrollPane();
private final JTable table = new JTable(data,header);
public static void main(String args[]) {
try {
test frame = new test();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the frame
*/
public test() {
super();
setBounds(100, 100, 781, 412);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
try {
jbInit();
} catch (Throwable e) {
e.printStackTrace();
}
GtFromDb db=new GtFromDb();
try {
data=db.getClient();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
header=new Vector<String>();
header.add("Imones pavadinimas");
header.add("vardas");
header.add("pavarde");
header.add("salis");
header.add("Adresas");
header.add("telefonas");
}
private void jbInit() throws Exception {
getContentPane().setLayout(null);
getContentPane().add(pridetiNaujaButton);
pridetiNaujaButton.setText("Prideti nauja");
pridetiNaujaButton.setBounds(0, 0, 106, 26);
getContentPane().add(pasalintiButton);
pasalintiButton.setText("Pasalinti");
pasalintiButton.setBounds(112, 0, 106, 26);
getContentPane().add(redagotiButton);
redagotiButton.setText("Redagoti");
redagotiButton.setBounds(224, 0, 106, 26);
getContentPane().add(paieskaButton);
paieskaButton.setText("Paieska");
paieskaButton.setBounds(336, 0, 106, 26);
getContentPane().add(scrollPane);
scrollPane.setBounds(10, 48, 745, 316);
scrollPane.setViewportView(table);
}
public class GtFromDb
{ Connection connect;
Statement zadanie;
String sql;
ResultSet dane;
// Map<String,String> carmap =new HashMap<String,String>();
// Map<String,String> ownmap =new HashMap<String,String>();
void DbConnection() throws SQLException
{
String baza="jdbc:odbc:dielektric_repair";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}catch(Exception e){System.out.println("Connection error");}
connect = DriverManager.getConnection(baza,"","");
}
public Vector getClient() throws Exception
{
Vector <Vector<String>> clientVector=new Vector<Vector<String>>();
try
{DbConnection();
PreparedStatement zadanie = connect.prepareStatement("SELECT * FROM Clients");
dane = zadanie.executeQuery();
while(dane.next()) {
Vector <String> client=new Vector<String>();
String imonesPav=dane.getString("Imones_pavadinimas");
String vardas = dane.getString("Vardas");
String pavarde = dane.getString("Pavarde");
String salis = dane.getString("Salis");
String adresas=dane.getString("Adresas");
String telefonas = dane.getString("Telefonas");
if (imonesPav != null) {imonesPav = imonesPav.trim();
client.add(imonesPav);}
if (vardas != null) {vardas = vardas.trim();
client.add(vardas);}
if (pavarde != null) {pavarde = pavarde.trim();
client.add(pavarde);}
if (salis != null) {salis =salis.trim();
client.add(salis);}
if (adresas != null) {adresas =adresas.trim();
client.add(adresas);}
if (telefonas != null) {telefonas = telefonas.trim();
client.add(telefonas);}
}zadanie.close();
}catch(SQLException e){}
return clientVector;
}
}
public JScrollPane getScrollPane() {
return scrollPane;
}
}