Temporary tables and connection pool

别来无恙 提交于 2019-12-13 02:49:58

问题


I use connection pooling provided by JBoss 7 and I do a connection.close() after every action.

But when I create a temporary table, it does not remain for the current user because he is using a new session from the database (due to connection.close() and pooling).

For example, I create a temp table in an action. The user changes page. The new action has to do queries in temp table but this does not exist anymore.

So, I really don't know how to provide temporary tables with this kind of architecture.


回答1:


Temporary tables in combination with connection pooling means request scope for the temporary tables. You'd like to have session scope temporary tables.

I am not aware of an out-of-the box solution. So options are

  1. Create normal tables with a prefix/suffix to associate these with a user
  2. Use the same connection for a user throughout the whole session
  3. Rewrite the application: Instead of temporary tables, read the data completely, and store it in the HTTP session. Possibly the database can paginate so there is no need to cache intermediate results etc.

Options 1 and 2 require cleanup, especially if the session is not shut down properly. Option 2 possibly requires many resources. So I would investigate the 3rd option, even if it seems to be the most cumbersone one.



来源:https://stackoverflow.com/questions/18121386/temporary-tables-and-connection-pool

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!