我以前是做.net 的,数据库操作从来没有像java这么复杂的,现在我一直不明白Statement是用来干什么的, 还有建立了Connection ,不用打开就可以操作吗?怎么没有open方法呀
还有以下这两打语句对吗?(t是返回一个Statement)
ResultSet rs=t.getStatement().executeQuery("select count(*) from biao");
int c=t.getStatement().executeUpdate("delete from biao where id=2");System.out.println(rs.getInt(1));
可以一起这么写吗??
谢谢前辈们指点!

解决方案 »

  1.   

    http://hmilyld.cn/post/398.htm
    看下这个,呵呵。
      

  2.   

    应该是可以的Connection,Statement,ResultSet,把这几个类搞清楚就直到怎么来做了 .
      

  3.   

    先建立一个statement变量,每次执行一次就关闭一次
    try{
    PreparedStatement stmt = t.t.getStatement();
    ResultSet rs=stmt.executeQuery("select count(*) from biao");
    rs.close();
    stmt.close();
    stmt = t.t.getStatement();
    int c=t.getStatement().executeUpdate("delete from biao where id=2");
    catch(Exception e){}
    finally{
    stmt.close();
    }