| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 451 人关注过本帖
标题:用结果集插入longtext为何出错?
只看楼主 加入收藏
msl12
Rank: 1
等 级:新手上路
帖 子:152
专家分:0
注 册:2015-2-6
结帖率:25%
收藏
 问题点数:0 回复次数:2 
用结果集插入longtext为何出错?
代码如下:
------------------------------------------------------------
import *;
import java.sql.*;

public class Test17 {
    public static String URL="jdbc:mysql://localhost:3306/lll";
    public static String USER="root";
    public static String KEY="1";

    public static void main(String args[]) throws Exception {
        Connection con=DriverManager.getConnection(URL, USER, KEY);
        String sql="select * from test2";
        PreparedStatement ps=con.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
        ResultSet rs=ps.executeQuery();
        rs.moveToInsertRow();
        File file=new File("C:\\Users\\lll\\Desktop\\JAVA\\long.txt");
        rs.updateString("name", "small_test2");
        rs.updateAsciiStream("note", new FileInputStream(file), file.length());    /*显示这里出错?

    Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query       must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.*/

        rs.insertRow();
        
        rs.close();
        ps.close();
        con.close();
    }
   
    public static void print(ResultSet rs) throws Exception {
        while (rs.next()) {
            System.out.println("编号:"+rs.getString(1));
            System.out.println("姓名:"+rs.getString(2));
            System.out.println("年龄:"+rs.getString(3));
            System.out.println("性别:"+rs.getString(4));
            System.out.println("生日:"+rs.getString(5));
            System.out.println();
        }
    }
}
2015-11-12 19:42
msl12
Rank: 1
等 级:新手上路
帖 子:152
专家分:0
注 册:2015-2-6
收藏
得分:0 
再顶一下。
2015-11-12 23:30
msl12
Rank: 1
等 级:新手上路
帖 子:152
专家分:0
注 册:2015-2-6
收藏
得分:0 
再顶再顶
2015-11-14 12:11
快速回复:用结果集插入longtext为何出错?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.020526 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved