Null ResultSet and how to fill it
I have the next code:
ResultSet rs= null;
TipoEstablecimientoHotel tipoEstablecimiento = new TipoEstablecimientoHotel(rs);
Of course, the second line goes into a null pointer exception, so I want to initialize tha "rs", but I don't want the data coming fro开发者_如何学Gom a database at this point. I'm lost with it.
We have no idea what TipoEstablecimientoHotel
does, or why it needs a result set. If it needs it at the point of construction then either you need to defer constructing TipoEstablecimientoHotel
until you've got the results, or you need to redesign it so you can give it the data later.
Basically, a problem like this should be taken as a suggestion to take a step back and consider your design - think about what should need data when, and adjust the design to meet those needs.
精彩评论