i've been kind of stuck week now. thought easy in java in php. here goes:
after gathering data database , placing them in jtable, wanted add feature edit or delete row in jtable , in database. here's code
private void getemployees(string query){ defaulttablemodel dm = new defaulttablemodel(0, 0){ @override public boolean iscelleditable(int row, int column) { return false; } }; string header[] = new string[] {"<html><b>id</b></html>", "<html><b>name</b></html>", "<html><b>birthday</b></html>", "<html><b>department</b></html>", "<html><b>date hired</b></html>", "<html><b>position</b></html>" , "<html><b>modify</b></html>" }; dm.setcolumnidentifiers(header); emplist.setmodel(dm); emplist.setrowselectionallowed(false); try { connection conn = drivermanager.getconnection("jdbc:mysql://localhost:3306/employee?zerodatetimebehavior=converttonull","root","passwords"); statement stmt = conn.createstatement(); resultset rs; rs = stmt.executequery(query); while(rs.next()){ vector<object> data = new vector<object>(); data.add(rs.getstring("id")); data.add(""+rs.getstring("lname")+", "+rs.getstring("fname")); data.add(rs.getstring("bday")); data.add(rs.getstring("dept")); data.add(rs.getstring("datehire")); data.add(rs.getstring("position")); data.add("delete"); dm.addrow(data); } } catch (exception e) { system.err.println("got exception! "); system.err.println(e.getmessage()); } } see data.add("delete")? i've tried placing , href tag linked function apparently doesn't work. tried putting in void function there doesn't accept void. tried using jbutton , eventlistener keep getting lost in track. i'm sorry stupid questions. i'm still beginner hoping learn more.
Comments
Post a Comment