开发者

Null ResultSet and how to fill it

开发者 https://www.devze.com 2023-03-05 03:13 出处:网络
I have the next code: ResultSet rs= null; TipoEstablecimientoHotel tipoEstablecimiento = new TipoEstablecimientoHotel(rs);

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消