MySQL使用blob插入歌曲文件

欧阳子遥 学生  2020-08-02 10:01:45
这是用完整的sql一句话写的,没用用占位符和IO,歌曲检查后确实插入了




这是使用占位符和IO的,检查了sql好久,sql语句不知道哪里有错,希望路过的大神看一下


报错信息
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 'k3???0??\0?…?é??bé’– \0?1U?bN?‰‰+s ?\0(\0???1U:\0 \0?bN?‰‰+s)\0TPE1\0\0\0\0' at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3536)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3468)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1957)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2107)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2648)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2086)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2371)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2289)
at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2274)
at mysql.mysql_bigwenjjian.bigStory(mysql_bigwenjjian.java:24)
at mysql.mysql_bigwenjjian.main(mysql_bigwenjjian.java:59)
...全文
499 1 收藏 1
写回复
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
qybao 2020-08-03
你把文件读入一个byte数组,然后用setBytes试试,即 byte[] data = read_data_from_file(); //怎么读文件就不用多说了吧 pstmt.setBytes(2, data);
回复
发动态
发帖子
Java SE
创建于2007-09-28

6.1w+

社区成员

Java 2 Standard Edition
申请成为版主
社区公告
暂无公告