你的这个字段肯定不是LONG,而是STRING,你检查一下!

解决方案 »

  1.   

    排除pengji(彭乃超)的情况是否和创建数据库的参数有关呢???
      

  2.   

    用CLOB類型.long可能在以後的版本中不再支持.
      

  3.   

    猪肉伦你个问题不是说换了driver就行了吗??
      

  4.   

    你连那里的的啊unix oralce7。2。3
      

  5.   

    用clob要对程序作很大的修改
    是吗???
    我的程序已经写好了
      

  6.   

    你的程序是怎么写的?必须要用PreparedStatement以流的方式插入才行
      

  7.   

    直接用Statement.executeQuery("insert ...")
      

  8.   

    ORA-01704 string literal too longCause: The string literal is longer than 4000 characters.Action: Use a string literal of at most 4000 characters. Longer values may only be entered using bind variables我查www.oracle.com
    怎么解决呢???
      

  9.   

    LONG, RAW, LONG RAW, VARCHAR2
    You can use the piecewise capabilities provided by OCIBindByName(), OCIBindByPos(), OCIDefineByPos(), OCIStmtGetPieceInfo() and OCIStmtSetPieceInfo() to perform inserts, updates or fetches involving column data of these types. 
    你用OCI的话可以用上面的Bind的方法,
    你用jdbc则要用流来输入。
    下面JDBC用文件流读写LONG字段的例子:
    /*
     * This example shows how to stream data from the database
     */import java.sql.*;
    import java.io.*;class StreamExample
    {
      public static void main (String args [])
           throws SQLException, IOException
      {
        // Load the driver
        DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());    // Connect to the database
        // You can put a database name after the @ sign in the connection URL.
        Connection conn =
          DriverManager.getConnection ("jdbc:oracle:oci8:@", "scott", "tiger");    // It's faster when you don't commit automatically
        conn.setAutoCommit (false);    // Create a Statement
        Statement stmt = conn.createStatement ();    // Create the example table
        try
        {
          stmt.execute ("drop table streamexample");
        }
        catch (SQLException e)
        {
          // An exception would be raised if the table did not exist
          // We just ignore it
        }    // Create the table
        stmt.execute ("create table streamexample (NAME varchar2 (256), DATA long)");    // Let's insert some data into it.  We'll put the source code
        // for this very test in the database.
        File file = new File ("StreamExample.java");
        InputStream is = new FileInputStream ("StreamExample.java");
        PreparedStatement pstmt = 
          conn.prepareStatement ("insert into streamexample (data, name) values (?, ?)");
        pstmt.setAsciiStream (1, is, (int)file.length ());
        pstmt.setString (2, "StreamExample");
        pstmt.execute ();    // Do a query to get the row with NAME 'StreamExample'
        ResultSet rset = 
          stmt.executeQuery ("select DATA from streamexample where NAME='StreamExample'");
        
        // Get the first row
        if (rset.next ())
        {
          // Get the data as a Stream from Oracle to the client
          InputStream gif_data = rset.getAsciiStream (1);      // Open a file to store the gif data
          FileOutputStream os = new FileOutputStream ("example.out");
          
          // Loop, reading from the gif stream and writing to the file
          int c;
          while ((c = gif_data.read ()) != -1)
            os.write (c);      // Close the file
          os.close ();
        }
      
        // Close all the resources
        if (rset != null)
          rset.close();
        
        if (stmt != null)
          stmt.close();
        
        if (pstmt != null)
          pstmt.close();    if (conn != null)
          conn.close();
      }
    }
      

  10.   

    直接用Statement.executeQuery("insert ...") 当然不行!
    这样写也可以:
    PreparedStatement p=con.prepareStatement("insert...values(?)");
    String str="大字符串";
    p.setCharacterStream(1,new java.io.StringReader(str),str.length());
    p.executeUpdate();
      

  11.   

    如果排除我前面说的问题的话,我觉得应该是驱动的问题!
    TO: ldgs(钢锁)为什么直接用Statement.executeQuery("insert ...")不行啊!?请教!
      

  12.   

    Statement 对象用于执行不带参数的简单 SQL 语句;
    PreparedStatement 对象用于执行带或不带 IN 参数的预编译 SQL 语句;
    用较小的块传递大型的数据,让程序在数据库内部运行得更高效,可通过将 IN 参数设置为 Java 输入流来完成。
    当语句执行时,JDBC 驱动程序将重复调用该输入流,读取其内容并将它们当作实际参数数据传输。
    -----摘自JDK document
      

  13.   

    那直接用Statement.executeQuery("insert ...")也是可以的喽!?是吗?!
      

  14.   

    String sSql = "INSERT INTO test(content) VALUES(?)";
    stmt = conn.prepareStatement(sSql);
    String content="你的内容";
    byte[] pic = content.getBytes();
    //ByteArrayInputStream bais = new ByteArrayInputStream(pic);
    InputStreamReader bais = new InputStreamReader(new ByteArrayInputStream(pic));
    stmt.setCharacterStream(1, bais, pic.length);
    stmt.execute();当超过4000个字符时就不能直接用insert了
    要用流式输入
    上面的代码就是用来解决此问题明天结帐
    欢迎大家继续讨论
      

  15.   

    blob存在同样的问题,我解决了,好麻烦,
    了解到oracle好笨啊
      

  16.   

    遇到过,不用存储过程就可以了
    因为long作为参数的时候,最多只能是32k
      

  17.   

    qry  = "update news set content=? where newsid=1";
    PreparedStatement pstmt = con.prepareStatement(qry);
    StringReader rd = new StringReader(content);
    pstmt.setCharacterStream (1, rd, content.length());
    pstmt.executeUpdate();
    pstmt.close();