首先插入代码
import java.io.* ;
import java.sql.* ;
public class TestCLOB1 
{
public static final String DBDRIVER = "org.gjt.mm.mysql.Driver";//定义数据库驱动程序
public static final String DBURL = "jdbc:mysql://localhost:3306/mldn";//连接地址
public static final String NAME = "root";//用户名
public static final String PASSWORD = "sqladmin";//密码
public static void main(String[] args) throws Exception
{
Connection con = null ;
PreparedStatement presta = null ;
Class.forName(DBDRIVER);//加载驱动程序
con = DriverManager.getConnection(DBURL,NAME,PASSWORD);
System.out.println(con + "连接正常!");
String name = "xdw";
String sql = "INSERT INTO userclob(name,note) VALUES (?,?) " ;
presta = con.prepareStatement(sql);
File f = new File("d:" +File.separator + "mm.txt");
InputStream input = new FileInputStream(f);//读取输入流
presta.setString(1,name);
presta.setAsciiStream(2,input,(int)f.length()) ;
presta.executeUpdate();//执行更新
con.close();
}
}
本代码要实现的是读取CLOB数据,在执行之后发现如下错误
Exception in thread "main" java.sql.SQLException: Incorrect string value: '\xB6\
xA8\xD2\xE5My...' for column 'note' at row 1
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:946)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:3283)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.ja
va:1332)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:1604)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:1519)
        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java
:1504)
        at TestCLOB1.main(TestCLOB1.java:32)
请哪位帮忙指点一下!!!!!!!