当前位置:首页
开发技术指南» 文章正文
    引言:

    摘要: #include<iostream.h> class myclass { private: int val; public: myclass(int i=0) {val=i;cout<<"val="<<val<<endl;} myclass(myclass &cp); void set(int i); int sh......
 ·怎样验证一个sql语句是否有效    »显示摘要«
    摘要: 怎样验证一个sql语句是否有效? 不是通过查询分析器 而是通过一段代码来检查? ......


为什么我的jdbc程序只能访问 type 为 system 的表,。。。。。

为什么我的jdbc程序只能访问   type   为   system   的表,而不能访问   type   为user   的表呢,有什么区别吗,怎么改才能访问,user自己建立的表呢,请高手赐教  
  代码如下:  
  import   java.sql.*;  
  public   class   JDBCTest  
  {  
  public   static   void   main(String[]   args)  
  {  
  try  
          {  
          Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");  
          }  
          catch(ClassNotFoundException   ew)  
          {  
          System.out.println(ew.getMessage());  
          }  
          try  
          {  
          Connection   con=DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;   DatabaseName=rainly1","sa","");  
          Statement   sql=con.createStatement();  
                                          System.out.println(sql);  
          ResultSet   res=sql.executeQuery("select   *   from   sysusers");  
          while(res.next())  
          {  
          String   id=res.getString(1);  
          String   name=res.getString(2);  
          String   sex=res.getString(3);  
          String   address=res.getString(4);  
          String   qq=res.getString(5);  
          System.out.print("编号"+id);  
          System.out.print("姓名"+name);  
          System.out.print("性别"+sex);  
          System.out.print("地址"+address);  
          System.out.print("QQ:"+qq+"\n");  
          }  
        System.out.println();  
          }  
          catch(SQLException   e)  
          {  
          System.out.println(e.getMessage());  
          }  
  }  
  }

NO.1   作者: matq2008

权限改为你访问的用户能使用就行了

NO.2   作者: sharkhuang

你访问数据库的用户权限吧


    摘要: 在页面上编写好的sql语句,然后保存到数据库中,如何查询该语句是否正确, 就像查询分析器中的语法检查?而不是执行该sql语句? 比如:select * from aa 这句是正确的 但是写成了 select * form aa 通过语法检查,指出该句不正确? ......
» 本期热门文章:

©2000-2007 All Rights Reserved. 最佳浏览:1024X768 MSIE