本帖最后由 崔增阳 于 2013-5-29 13:57 编辑
package mysql;
import java.sql.*;
import java.io.*;
public class ClobTest {
public static void main(String[] args) throws Exception{
create();
}
static void create()throws Exception{
Connection conn = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
conn = JdbcUtils.getConnection();
String sql="insert into clob_test(big_text)valus(?)";
ps = conn.prepareStatement(sql);
File file=new File("e:\\CRUD.java");
Reader reader=new BufferedReader(new FileReader(file));
ps.setCharacterStream(1, reader, (int)file.length());
ps.executeUpdate();
reader.close();
} finally {
JdbcUtils.free(rs, ps, conn);
}
}
}
Exception in thread "main" com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'valus('package mysql;\r\n\r\nimport java.sql.Connection;\r\nimport java.sql.Resu' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1054)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4120)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4052)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2503)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2664)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2815)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2155)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2458)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2375)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2359)
at mysql.ClobTest.create(ClobTest.java:22)
at mysql.ClobTest.main(ClobTest.java:9)
|