我就是使用了getString没有错误啊?你检查检查又没有别的错误。实在不行用getClob看看

解决方案 »

  1.   

    我用getString读取text字段发生异常,大家能给一个例子么?
    如果text字段是空的情况也要考虑进去
      

  2.   

    sqlserver的驱动的问题,你要按顺序get,比如getString(1)..getString(2),必须按照这样的顺序取值,不知道你是不是用的microsoft的driver???
      

  3.   

    一般来说数据集ResultSet中可以用多种getXXXX方法来取出值:
    比如:
        try {
            // Create a result set containing all data from mysql_all_table
            Statement stmt = connection.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM mysql_all_table");
        
            // Fetch each row from the result set
            while (rs.next()) {
                boolean bool = rs.getBoolean("col_boolean");
                byte b = rs.getByte("col_byte");
                short s = rs.getShort("col_short");
                int i = rs.getInt("col_int");
                long l = rs.getLong("col_long");
                float f = rs.getFloat("col_float");
                double d = rs.getDouble("col_double");
                BigDecimal bd = rs.getBigDecimal("col_bigdecimal");
                String str = rs.getString("col_string");
                Date date = rs.getDate("col_date");
                Time t = rs.getTime("col_time");
                Timestamp ts = rs.getTimestamp("col_timestamp");
                InputStream ais = rs.getAsciiStream("col_asciistream");
                InputStream bis = rs.getBinaryStream("col_binarystream");
                Blob blob = rs.getBlob("col_blob");
            }
        } catch (SQLException e) {
        }
    但是一般来说只用如下getString方法:
        try {
            // Create a result set containing all data from my_table
            Statement stmt = connection.createStatement();
            ResultSet rs = stmt.executeQuery("SELECT * FROM my_table");
        
            // Fetch each row from the result set
            while (rs.next()) {
                // Get the data from the row using the column index
                String s = rs.getString(1);
        
                // Get the data from the row using the column name
                s = rs.getString("col_string");
            }
        } catch (SQLException e) {
        }
    这样做就不会出现异常。
      

  4.   

    谢谢楼上的,搞定了!
    用select * from talbename就OK了!