Check the data of less
/* *
* query library name
*
* @ return
*/
Public ListGetLibList () {
ListResult=new ArrayList ();
Try {
String SQL="select SCHEMA_NAME from information_schema. Schemata";
//create the SQL statement execution,
PreparedStatement ps=conn. PrepareStatement (SQL);
The ResultSet rs=ps. ExecuteQuery ();
();//the ResultSetMetaData rs_metaData=https://bbs.csdn.net/topics/rs.getMetaData
While (rs), next ()) {
String a=new String ();
SCHEMA_NAME a=rs. Get string (" ");
Result. The add (a);
}
return result;
} the catch (Exception e) {
return result;
}
}
CodePudding user response:
For example: there are ten data, can only be found out seven, skip cycle three timesCodePudding user response:
But his odds swallow exceptions is not a good habit} the catch (Exception e) {
e.printStackTrace();
return result;
}
And see whether the fault database
CodePudding user response:
You don't have a skip this code, circulation situation,If the rs. Next () returns false, the loop is directly over, how can skip?
If the rs. Next () returns true, it will enter the loop body, since entered the loop body, must not skip the circulation situation,
In addition, the abnormal no processing, code of swallow exceptions, are the least desirable, when the application problems, swallow exceptions will increase the difficulty of the problem screening,
The original poster of the code, the most likely reason why there are two problems:
1. Program to connect account permissions not to complete, so the query data may not be full; (of course, the original poster said permissions tube is enough, that's not to consider)
2. In the process of circulation throws exceptions, for example, circulation article 8 data when an exception is thrown, then the exception is swallowed, directly back to the seven records,
CodePudding user response: