java setBinaryStream error for mysql
2012-12-06 08:42
260 查看
Class.forName(driver);
Connection conn=DriverManager.getConnection(url, user, password);
String sql="insert into [test] ([name],[img])values(?,?)";
InputStream is=new FileInputStream(new File("src/lsnu/lgf/saveimage/haha.jpg"));
System.out.println("len="+is.available());
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, "name");
ps.setBinaryStream(2, is,is.available());
System.out.print(ps.execute());
presentation:Exception in thread "main" java.sql.SQLException: 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 '[test] ([name],[img])values('ggggg',_binary'ertwertwederywgadfhsdfhgf
change:
String sql="insert into test (name,img)values(?,?)";
is ok;
Connection conn=DriverManager.getConnection(url, user, password);
String sql="insert into [test] ([name],[img])values(?,?)";
InputStream is=new FileInputStream(new File("src/lsnu/lgf/saveimage/haha.jpg"));
System.out.println("len="+is.available());
PreparedStatement ps=conn.prepareStatement(sql);
ps.setString(1, "name");
ps.setBinaryStream(2, is,is.available());
System.out.print(ps.execute());
presentation:Exception in thread "main" java.sql.SQLException: 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 '[test] ([name],[img])values('ggggg',_binary'ertwertwederywgadfhsdfhgf
change:
String sql="insert into test (name,img)values(?,?)";
is ok;
相关文章推荐
- [异常] com.mysql.jdbc.ServerPreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V
- com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V错误解决
- java.lang.AbstractMethodError: com.mysql.jdbc.PreparedStatement.setBinaryStream
- com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V问题原因
- com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V问题原因
- 关于Mysql数据库longblob格式数据的插入com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V问题分析
- com.mysql.jdbc.PreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V问题原因
- Java与mysql数据库编程中遇见“Before start of result set at com.mysql.jdbc.SQLError.createSQLException” 的解决办法
- 【MySQL】连接MySQL时,字符无法识别(java.sql.SQLException: Unknown character set index for field '224' received )
- 正确使用MySQL JDBC setFetchSize()方法解决JDBC处理大结果集 java.lang.OutOfMemoryError: Java heap space
- 正确使用MySQL JDBC setFetchSize() setMaxRows()方法解决JDBC处理大结果集 java.lang.OutOfMemoryError: Java heap space
- org.apache.commons.dbcp.DelegatingPreparedStatement.setBinaryStream(ILjava/io/InputStream;J)V
- mysql 高版本jdbc驱动程序 使用PreparedStatement.setBinaryStream方法报错及解决办法
- MySQL Error Query database. Causejava.sql.SQLException: Incorrect key file for table ‘/tmp/#sql_181c
- 正确使用MySQL JDBC setFetchSize()方法解决JDBC处理大结果集 java.lang.OutOfMemoryError: Java heap space
- Java与mysql数据库编程中遇见“Before start of result set at com.mysql.jdbc.SQLError.createSQLException” 的解决办法
- java.lang.AbstractMethodError: com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.setBinaryStream(IL
- java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for
- Java与mysql数据库编程中遇见“Before start of result set at com.mysql.jdbc.SQLError.createSQLException” 的解决办法
- com.mysql.jdbc.ServerPreparedStatement.setCharacterStream(ILjava/io/Reader;J)V