RT,直接上源代码:package compress;import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class TestBlob {

String Url = "jdbc:mysql://localhost:3306/test?user=root&password=123456&useUnicode=true&characterEncoding=gbk";
String driverName = "org.gjt.mm.mysql.Driver";
Connection conn;
File file;

public Connection getConnection() {
Connection connection = null;
try {
Class.forName(driverName).newInstance();
connection = DriverManager.getConnection(Url);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}

return connection;
}

public boolean putImage(){
conn = getConnection();
file = new File("c:\\1.gif");
String sql = "insert into TestImage(id,image) values(?,?)";
PreparedStatement psmtStatement = null;
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
psmtStatement = conn.prepareStatement(sql);
psmtStatement.setInt(1, 1);
psmtStatement.setBinaryStream(2, inputStream, (int)file.length());

psmtStatement.executeUpdate();

} catch (FileNotFoundException e) {
e.printStackTrace();
return false;
} catch (SQLException e) {
e.printStackTrace();
return false;
} finally{
if(psmtStatement!=null){
try {
psmtStatement.close();
} catch (SQLException e) {
e.printStackTrace();
}
psmtStatement = null;
}

}
return true;
}

public static void main(String[] args) {
TestBlob tb = new TestBlob();
System.out.print(tb.putImage());
}}
报异常:
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 '?????í??*?·?…s?¨§??!3è??é???z?@?“ó#?? ??M\0°???????=????
??7??CA?I??$XE' 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 compress.TestBlob.putImage(TestBlob.java:49)
at compress.TestBlob.main(TestBlob.java:62)
false
请问怎么办啊?