开发者

Java - Retrieving data from database based on user logged in

If say, I logged in to my own website, I want to return data that I have submitted to the database. Problem is, how do I query the database to return only my data?

I understand that the query would like this using PreparedStatement:

select * from TableName where Username = ?

I want to add the parameter d开发者_StackOverflowepending on who is logged in, not just 1 person. Sorry I know I might not explained it well, please ask if not clear.

Edit: If I login, I expect the viewreports.jsp to show the reports I have submitted


The only thing you can do is to:

  • Add a column to all your database tables with an id or a name of whoever submitted it

  • Alter your insert queries to write the name or id of logged in user

  • Alter queries for all such tables to have one additional condition, which is if the logged in user matches the value from that column.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜