Forum Stats

  • 3,839,341 Users
  • 2,262,485 Discussions
  • 7,900,938 Comments

Discussions

(need help) my aplication not error but why not working ?

936150
936150 Member Posts: 3
edited May 14, 2012 11:13AM in Java Desktop Applications
i want load data to combobox from database,and this is my code....no error but why not working ?




private void BoxhobyActionPerformed(java.awt.event.ActionEvent evt) {
try {
String dbname="jdbc:odbc:gaji";//nama odbc
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(dbname,"admin","admin");//user & pasword
String sql = "select pekerjaan from gaji order by pekerjaan";
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery(sql);
while (rs.next())
{
Boxhoby.addItem(""+rs.getString("pekerjaan"));
}

statement.close();

con.close();
}catch(Exception x)
{
JOptionPane.showMessageDialog(null,"error:"+x,"gagal",JOptionPane.WARNING_MESSAGE);

}

Answers

This discussion has been closed.