When you do the permissions, you find the permissions for the roles in the Auth permissions through the Roleid in role roles.
SQL statements:
SELECT AuthName from Auth where authId in (1,2,3,4,5)
In the back of the thing is the role of the various permissions of the ID, you can find the 1,2,3,4,5 corresponding permissions name.
So the combination of Auth table, directly used, the SQL statement is:
Select AuthName from Auth where authId in (SELECT authids from role where roleid=1)
The 1,2,3,4,5 is the content that is found in the back. In practice, this can be an error, and the expected results cannot be detected. In the back of the content should be ("Field 1", "Field 2", ...), the above kind of check out, it should be this format in ("1,2,3,4,5"), the 1,2,3,4,5 five as a string.
Then in the Java code, you can avoid this problem, mainly because of the Java string concatenation, you can easily assemble in the following parentheses in the data format.
The following example code is to achieve the desired result.
Public Static voidMain (string[] args)throwsException {//TODO auto-generated Method StubDbutil dbutil=NewDbutil (); Connection Connection=Dbutil.getcon (); String hql= "Select Authids from role where roleid=1"; PreparedStatement PreparedStatement2=connection.preparestatement (HQL); ResultSet ResultSet2=Preparedstatement2.executequery (); String Authid=NULL; while(Resultset2.next ()) {Authid=resultset2.getstring ("Authids"); System.out.println ("Authids:" +resultset2.getstring ("Authids")); } String SQL= "Select AuthName from Auth where authId in (" +authid+ ")";//splicing SQL statements PreparedStatement PreparedStatement=connection.preparestatement (SQL); ResultSet ResultSet=Preparedstatement.executequery (); while(Resultset.next ()) {System.out.println ("AuthName:" +resultset.getstring ("AuthName")); } }