JiveJdon Community Forums
在线216人 Home | 论坛 | 培训咨询 | 精华 | 查搜 | 注册 | 登陆 |
首页 » 论坛 » J2EE/JavaEE/JEE/EJB/JSF等技术讨论
???en_US.forumThreadPrev.name??? 上一主题
Go back to the topic listing   返回主题列表
???en_US.forumThreadNext.name??? 下一主题
这个主题共有 2 回复 / 1 页 [ ]  发表新帖子  回复该主题贴
zpsw

发表文章: 2
注册时间: 2006年10月17日 21:20
给他发消息
请高人指点 发表: 2006年10月17日 21:26 回复
小弟遇到一难题,代码如下:


String[] DML_INSERT = { "insert", "into", "(", ")", "values", "(", ")"
private void InsertDone(Map map){
Map infoTable = new HashMap();
// 添加表名
infoTable.put(
"name", map.get(DML_INSERT[1]));
// 获得表中的字段
String[] column = (String[]) map.get(DML_INSERT[2]);
// 添加字段
for (int i = 0; i < column.length; i++) {
infoTable.put(column[i],
"");
}
//获得要插入的值
String[] value = (String[]) map.get(DML_INSERT[5]);
//添加值
for(int j=0;j< value.length;j++){
value[j] =
"'"+value[j]+"'";
infoTable.put(value[j],
"");
}
// 保存创建结构
Container.serial(infoTable, (String) map.get(DML_INSERT[1]));

}
private Map InsertPrepare(String formatSrcipt){
Map MapInfo = new HashMap();
String insertType = StringUtils.substringBefore(formatSrcipt,
" ");
if (DML_INSERT[1].equals(insertType.trim())) {
// 检查类型是否是 TABLE
String tableName = StringUtils.substringBetween(formatSrcipt,
DML_INSERT[1], DML_INSERT[2]);
if (tableName == null || tableName.trim().length() == 0) {
System.err.println(
"无效DML脚本,缺少表名");
return null;
}
MapInfo.put(DML_INSERT[1], tableName.trim());
String column = StringUtils.substringBetween(formatSrcipt,DML_INSERT[2], DML_INSERT[3]);
if (column == null || column.trim().length() == 0) {
System.err.println(
"无效DML脚本,缺少字段");
return null;
}
String[] columnArr = column.split(
",");
MapInfo.put(DML_INSERT[2], columnArr);
String values = StringUtils.substringBetween(formatSrcipt,DML_INSERT[5],DML_INSERT[6]);
String[] columnArr1 = values.split(
",");
MapInfo.put(DML_INSERT[5],columnArr1);
}else {
System.err.println(
"无效脚本,缺少关键字");
return null;
}

return MapInfo;
}


public static void main(String[] args) {
DMLSyntaxParserImpl dpl = new DMLSyntaxParserImpl();
dpl.opedo(
"insert into table5 (column1,column2) values (value1,value2)");
Map map = (Map) Container.fetchData(
"table5");
for (Iterator itr = map.k**Set().iterator(); itr.hasNext();) {
Object k** = itr.next();
System.out.println(k** +
":" + map.get(k**));


}

希望得到的结果是能将DML语句里的column1,column2,value1,value2提取出来,可得到的结果是column1,column2,'column1',column2'
小弟初学java,还希望哪位高人能帮我指点指点
jsp

发表文章: 1
注册时间: 2006年10月18日 14:01
给他发消息
Re: 请高人指点 发表: 2006年10月18日 14:02 回复
不太懂哦~我刚刚学习
zpsw

发表文章: 2
注册时间: 2006年10月17日 21:20
给他发消息
Re: 请高人指点 发表: 2006年10月19日 22:49 回复
有没有哪位大虾来帮帮小弟啊!!!!!!!!
这个主题有 2 回复 / 1 页 [ ]
???en_US.forumThreadPrev.name??? 上一主题
Go back to the topic listing   返回主题列表    返回页首  返回页首
???en_US.forumThreadNext.name??? 下一主题
热点TAG: AOP cache DDD EJB 集群 设计模式 Hibernate IOC JiveJdon OO RBAC Spring Struts
查询本论坛内 回复超过的热门帖子
快速发表回复
标题
 
粗体 斜体 下划线 插入图片 插入代码 插入url链接 插入附件
内容
 

解惑之道在J道 ,打造中国最具影响力的的企业软件社区
OpenSource JIVEJDON v3.0 Powered by JdonFramework Code © 2002-08 jdon.com

anti spam