Actually , i must admit , i did not knew about connecting with database but i am trying to learn , i want to insert data into jtable from Ms acess database , i have made a table called song_library there and also created the dsn as testy1...Also in the in init function where the jTable is called i have written the code for connecting to the databse!! And i also know there is some problem i my code, i am posting that part of the code here:
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
loadDB();
}
});
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void loadDB()
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:odbc:testy1");
Statement s = c.createStatement();
ResultSet rs = s.executeQuery("select * from song_library");
while (rs.next()) {
jTable2.add(rs.getString(2),new Label()) ;
}
} catch (Exception e) {
}
}