Calling a method?

okay. I wrote the above code and I need to call it from another class. how can I do it? plus it gives me this error with `DefaultTableModel prodt = (DefaultTableModel) protable.getModel();` . the error is non-static variable protable cannot be referenced from a static context. public static void refreshProtable() { try { Statement s1 = Db.connectDb().createStatement(); ResultSet rs1 = s1.executeQuery("SELECT * FROM product WHERE status='" + 0 + "'"); DefaultTableModel prodt = (DefaultTableModel) protable.getModel(); while (rs1.next()) { Vector v1 = new Vector(); v1.add(rs1.getString("pid")); v1.add(rs1.getString("pname")); v1.add(rs1.getString("sp_rt")); v1.add(rs1.getString("sp_wh")); v1.add(rs1.getString("um")); Statement s2 = Db.connectDb().createStatement(); ResultSet rs2 = s2.executeQuery("SELECT * FROM stock WHERE pid='" + rs1.getString("pid") + "'"); if (rs2.next()) { v1.add(rs2.getString("qty")); } prodt.addRow(v1); s2.close(); } s1.close(); } catch (Exception e) { e.printStackTrace(); } }

以上就是Calling a method?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏