用结果集插入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();
}
}
}