I have a method in a class , which returns a String.
This string is sql statement, which could be one or many in number.
I want to write a method, by which if there is one statement, it returns the statement. If there are multiple statements, then return each one at a time. How do I do this?
public String getSql() {
String insertSql = getInsertSQL();
logger.debug("retrieved sql from dao >>>>>>>" + insertSql);
StringTokenizer st = new StringTokenizer("+");
if(st.countTokens()>0) {
for(int i=0;i<st.countTokens();i++) {
insertSql = (String) st.nextElement();
logger.debug("retrieved sql from dao after tokanization >>>>>>>" + insertSql);
}
}
return insertSql;
}
I tried something like this: This would only give me the last token. How do I get each of the sql, but only one at a time?