应该是sql脚本使用不当,你的sql是什么?

解决方案 »

  1.   

    贴出你的sql
    你可以先在mysql里运行一下你的sql语句~
      

  2.   

    首先你要确定你的SQL是对的,还有你要有权限,没有权限也可能出现上面的错误。没看到你的邮箱呀,我可以发一个把相版从数据库中读,写到数据库中去的例子给你!
      

  3.   

    将SQL语句贴来看看,应该是SQL的错误,先将SQL语句独立运行看看。
      

  4.   

    四个本问题的贴子至今没有任何人可以回答,全部都是可以啊,行啊,没问题啊
    没有任何代码证明我的信箱是 [email protected]
    收到可行代码立刻结贴送分
    http://community.csdn.net/Expert/topic/3638/3638776.xml?temp=.6011927
    http://community.csdn.net/Expert/topic/3637/3637320.xml?temp=.0927698
    http://community.csdn.net/Expert/topic/3638/3638807.xml?temp=.9520227
    http://community.csdn.net/Expert/topic/3638/3638773.xml?temp=.4013636
      

  5.   

    插入/查询正常。的确可以,这是数据库一般的功能。
    try {
    Class.forName("org.gjt.mm.mysql.Driver").newInstance(); 
    String url ="jdbc:mysql://localhost/test?user=root&password=root&useUnicode=true&characterEncoding=gbk"; 

    Connection conn = DriverManager.getConnection(url);
    Statement stmt = conn.createStatement();
    stmt.execute("insert into test(myid) values (5)");
    stmt.close();
    PreparedStatement pstmt = null;
    String sql = "";
    File file = new File("c:\\kick.jpg");
    InputStream photoStream = new FileInputStream(file);
    sql = " UPDATE test SET photo = ? WHERE myid = 5" ;

    pstmt = conn.prepareStatement(sql);
    pstmt.setBinaryStream(1, photoStream, (int)file.length());
    pstmt.executeUpdate();
    pstmt.close();

    conn.close();
    } catch (Exception e) {
    e.printStackTrace();
    }
      

  6.   

    我用yahoo和sohu的发了过去。
      

  7.   

    将图片文件存入数据库的例子,请大家看一下:
    import java.sql.*;
    import java.io.*;
    class BlobTest {
     public static void main(String args[]){
       try{
       RandomAccessFile raf = new RandomAccessFile("DukeTest.bmp","rw");
       DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
       Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@your_server:1521:your_sid","user","password");
       PreparedStatement pstmt = conn.prepareStatement("INSERT INTO BlobTest valueS( ?, ? )" );
       pstmt.setString( 1, "photo1");
       File imageFile = new File("duke.gif");
       InputStream is = new FileInputStream(imageFile);
       pstmt.setBinaryStream( 2, is, (int)(imageFile.length()));
       pstmt.executeUpdate();
       pstmt = conn.prepareStatement("SELECT image FROM BlobTest WHERE name = ?");
       pstmt.setString(1, "photo1");
       ResultSet rs = pstmt.executeQuery();
       if(rs.next()){
       Blob blob = rs.getBlob(1);
       int length = (int)blob.length();
       byte [] _blob = blob.getBytes(1, length);
       raf.write(_blob);
       }
       System.out.println("Completed...");
       }catch(Exception e){
       System.out.println(e.getMessage());
       }
       }
    }