Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Servlet/JSP/JSF/JavaFX Script  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
reply to postflat modethreaded modego to previous topicgo to next topicgo to back
作者 Re:是不是SQL语句错了?!不解中... [Re:wind520sand]
beyond1984





发贴: 16
于 2005-09-23 10:32 user profilesend a private message to userreply to postsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

//底层UserHandle
...
public UserHandle(){
try{
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url = "jdbc:oracle:thinAngry127.0.0.1:1521:Beyond";
String user = "beyond";
String psd = "beyond";
tableName = "USER";
cn = DriverManager.getConnection(url,user,psd);
stmt = cn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); //是不是这里要指明stmt的类别允许更新才行,我是这么做的,可以更新,另外通过stmt.executeQuery(sql)应该可以更新!!
}
catch(Exception ex){
System.out.println(ex.toString());
}
}
public void addUser(String sql)throws Exception{
try{
stmt.executeQuery(sql);
}
catch(SQLException ex){
System.out.println("SQL statement is wrong!");
System.out.println(ex.toString());
throw ex;
}
}
}

//上层类DoSQL
...
public void addUser(){
UserHandle uh = new UserHandle();
String sql = "Insert Into USER Values('";
if(!checkIntegrality()){
return;
}
sql += (userID +"','"+ userName +"','"+ realName +"','"+ sex +"','"
+ address +"','"+ telephone +"','"+ mobile +"','"+ email+"')");
try{
uh.addUser(sql); //调用UserHandle.addUser();
}
catch(Exception ex){
errorInfo.addElement(ex.toString());
}
}

//我连的Oracle数据库,希望能给你点帮助,Good luck!


beyond1984 edited on 2005-09-23 10:42


话题树型展开
人气 标题 作者 字数 发贴时间
2897 是不是SQL语句错了?!不解中... wind520sand 471 2005-09-17 14:50
2448 Re:是不是SQL语句错了?!不解中... chengbd 49 2005-09-18 05:24
2416 Re:是不是SQL语句错了?!不解中... Ada1979 20 2005-09-23 19:07
2460 Re:是不是SQL语句错了?!不解中... wind520sand 701 2005-09-28 09:18
2490 Re:是不是SQL语句错了?!不解中... wind520sand 1046 2005-09-18 09:29
2402 Re:是不是SQL语句错了?!不解中... wind520sand 31 2005-09-20 08:30
2409 Re:是不是SQL语句错了?!不解中... chengbd 23 2005-09-20 09:02
2318 Re:是不是SQL语句错了?!不解中... why 191 2005-09-20 12:00
2453 Re:是不是SQL语句错了?!不解中... java菜鸟2005 88 2005-09-20 15:35
2391 Re:是不是SQL语句错了?!不解中... wind520sand 30 2005-09-20 18:16
2418 Re:是不是SQL语句错了?!不解中... dennisjl 53 2005-09-22 09:40
2411 Re:是不是SQL语句错了?!不解中... 沙漠小鸟 115 2005-09-22 13:07
2617 Re:是不是SQL语句错了?!不解中... beyond1984 1422 2005-09-23 10:32

reply to postflat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923