写了个简单的测试还是有这个问题File f = new File("D:\\Tomcat 6.0\\webapps\\shop\\upload\\01.jpg");
FileInputStream fis = new FileInputStream(f);
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/test", "root", "123456");
String sql = "insert into test(pic) values(?)";
PreparedStatement ps = conn.prepareStatement(sql);
System.out.println((int) f.length());
ps.setBinaryStream(1, fis, (int) f.length());
ps.executeUpdate();数据表只有一个自增长的id和LongBlob格式的pic.报错内容如下Exception in thread "main" com.mysql.jdbc.exceptions.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 '?‰?.?J?3??})???i7?(???ojD_??=òv?je??W;‘<jD!??x??‰WK???1üü???\05\0\0' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
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.java: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 com.eros.Test4.main(Test4.java:20)是哪里有问题啊?