首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

如何从一个select语句中截取表名

2012-01-11 
怎么从一个select语句中截取表名select*fromtableNamewhereid1 像这样一句select语句,如何才能截取到

怎么从一个select语句中截取表名
select   *   from                       tableName           where   id   =   "1 ";
像这样一句select语句,如何才能截取到 "tableName "呢?
不一定有where,也许会是order   by

[解决办法]
光字符串处理?
String str = "select * FROM tableName where id = \ "1\ " ";
Pattern wd = Pattern.compile( "(? <=from) +(\\w+).* ",
Pattern.CASE_INSENSITIVE);
Matcher m = wd.matcher(str);
if (m.find()) {
System.out.println(m.group(1));
}

热点排行
Bad Request.