java - Implement next and previous from database to form -


i have problem in implementing case.

1) examples show can use in following:

        try{            bd.conectarbasededatos();                 preparedstatement stmt;                 string sql=("select * cab_pedido a, det_pedido b a.numero = b.numero , a.cod_agencia = b.cod_agencia");                      system.out.println(sql);                 stmt = bd.conexion.preparestatement(sql,resultset.type_scroll_insensitive,resultset.concur_read_only);                  bd.result = stmt.executequery(sql);         }     catch (instantiationexception | illegalaccessexception | sqlexception e){ system.out.println(e);}          return rs; } 

this returns resultset , can use rs.next(). rs.previous(), etc solve problem, see comments should close rs , db connection. how dangerous that? can implement without closing resultset , connection? because when close resultset, not able data anymore.

2) store data hashmap or list possibility if want last or first values how can that?

i need next, prev, last, , first functions i'm not sure first implementation.

can give me advices of how start this.
need solutions, advices. duplicate means nothing.

i going try start answer here since don't have option comment yet understandable code , question is:

  • you have resultset want read first, last, previous, next etc set of data.
  • closing db connection resource
  • either use hashmap or list

well, have far, can read data resultset list or hashmap

secondly on closing resources, yes! should close db connection resources avoid memory leak. can adding finally block after catch block in code.

on hasmap or list. if aren't sure type of data reading resultset go implementation of list, e.g. arraylist<string>. if know data have keys , values, can go hashmap.

these general guidelines. if post more code, maybe can further.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -