Good day!

I'm trying to insert 17.5MB of data in my database using the code below, I
used the setBinaryStream() method in PreparedStatement class, but the errors
occured (see "ERROR" section). Then, I tried to insert 940kb of data then
it's work. Any idea on how to implement and support the large data insertion
in db? is there a need to reconfigure the Sybase? if so, how? or what
additional settings that i need? I'm using Sybase as my database, JDBC2.0,
JDK1.2 and ApacheJserv.

pls kindly help....

Thank's in advance,

John John Tobias


----------------------------------------------------------------------

public class SqlInsert {

    Connection conn = null;

    SqlInsert() {
        try {
            Class.forName("com.sybase.jdbc2.jdbc.SybDriver");

conn=DriverManager.getConnection("jdbc:sybase:Tds:dev1:4100/pass","pass","pass");

        }

        catch(Exception e){
            System.out.println( e );
        }
    }

public void Insert() {

     Statement stmt = null;
     ResultSet rs = null;
     InputStream istream = null;

     try {

        FileInputStream f = new FileInputStream( "filedata.txt" );
        PreparedStatement pstmt = conn.prepareStatement("insert into
               attachments(attID,msgID,filename,"
               + "contentType,encoding,attBody) values
               (10,'Dummy'," +"'dummy.dat','text/plain','7bit',?)" );

        pstmt.setBinaryStream(1, f, (int)f.available() );
        pstmt.execute();
        pstmt.close();
        f.close();
     }
     catch (Exception e){
       System.out.println( e );
     }
}

    public static void main( String []args ) {

        SqlInsert svr = new SqlInsert();
        svr.Insert();
        svr.close();
    }
}


----------------------------------------------------------------------
ERROR:


Exception in thread "main" java.lang.OutOfMemoryError
        at com.sybase.jdbc2.tds.TdsParam.literalValue(Compiled Code)
        at com.sybase.jdbc2.jdbc.ParamManager.processParamMarkers(Compiled
Code)
        at com.sybase.jdbc2.tds.Tds.language(Compiled Code)
        at com.sybase.jdbc2.jdbc.SybStatement.sendQuery(Compiled Code)
        at com.sybase.jdbc2.jdbc.SybPreparedStatement.sendQuery(Compiled
Code)
        at com.sybase.jdbc2.jdbc.SybStatement.execute(Compiled Code)
        at com.sybase.jdbc2.jdbc.SybPreparedStatement.execute(Compiled
Code)
        at SqlInsert.getStream(Compiled Code)
        at SqlInsert.main(Compiled Code)



______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to