executeQuery返回的resultset,游标是指在第一行纪录之前的,你在读数据前,要用rs.next()向下移动一下。具体参看jdbc文档

解决方案 »

  1.   

    这样应该成功.
    try{
    String sql="select * from test";
    statement=connection.prepareStatement(sql);
    ResultSet result=statement.executeQuery();
    while(result.next())
    {
    int    nid=result.getInt("id");
    String strid=new String("id  "+nid);
    System.out.println(strid);
    String name=result.getString("username");
    System.out.println("name  "+name);
    String sex=result.getString("old");
    System.out.println("sex  "+sex);  // int age=result.getInt("age");
     // String strAge=new String(""+age);
     // System.out.println("age  "+strAge); String phone=result.getString("birthday");
    System.out.println("phone  "+phone); }
    result.close();
    statement.close();  }catch(Exception e)
    {
    System.out.println(e.toString()); }
      

  2.   

    类似问题我也遇到过,通过JDBC-ODBC桥访问SQL Server数据库可以读出数值,就是不能读字符串。后来装了JDBC Driver for SQL Server,字符串全部用NVarChar、NText、NChar,就没问题了。
      

  3.   

    请问JDBC Driver for SQL Server下在以后如何安装,谢谢!
      

  4.   

    chenyuan_tongji(chenyuan_tongji)说的正确,照做吧
      

  5.   

    中文字符的非常正确
    追加的问题参照:
    http://www.csdn.net/expert/topic/647/647009.xml?temp=.2385218