Results 1 to 12 of 12
  1. #1
    tejz is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Question getBinaryStream,getBytes not Working for more than 1MB size

    Hi,,


    I stored image as blob type in the DB2. I set blob size is 20 MB.

    But when i am retrieving from DB, it was not working.

    I gives Nullpointer Exception.

    resultset.getBinaryStream,getBytes not Working for more than 1MB size of data.

    Exception :--



    java.lang.NullPointerException
    at com.ibm.db2.jcc.t4.j.b(j.java:293)
    at com.ibm.db2.jcc.b.jk.a(jk.java:4599)
    at com.ibm.db2.jcc.b.rf.a(rf.java:292)
    at com.ibm.db2.jcc.b.rf.b(rf.java:248)
    at com.ibm.db2.jcc.b.td.a(td.java:272)
    at com.ibm.db2.jcc.b.sd.getBytes(sd.java:99)
    at com.ibm.db2.jcc.b.td.getBytes(td.java:136)
    at org.apache.jsp.WEB_002dINF.jsp.agendapdf_jsp._jspS ervice(agendapdf_jsp.java:102)
    at org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:98)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:331)
    at org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:329)
    at org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:265)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.ApplicationDispatcher.inv oke(ApplicationDispatcher.java:630)
    at org.apache.catalina.core.ApplicationDispatcher.pro cessRequest(ApplicationDispatcher.java:436)
    at org.apache.catalina.core.ApplicationDispatcher.doF orward(ApplicationDispatcher.java:374)
    at org.apache.catalina.core.ApplicationDispatcher.for ward(ApplicationDispatcher.java:302)
    at org.apache.struts.chain.commands.servlet.PerformFo rward.handleAsForward(PerformForward.java:113)
    at org.apache.struts.chain.commands.servlet.PerformFo rward.perform(PerformForward.java:96)
    at org.apache.struts.chain.commands.AbstractPerformFo rward.execute(AbstractPerformForward.java:54)
    at org.apache.struts.chain.commands.ActionCommandBase .execute(ActionCommandBase.java:51)
    at org.apache.commons.chain.impl.ChainBase.execute(Ch ainBase.java:191)
    at org.apache.commons.chain.generic.LookupCommand.exe cute(LookupCommand.java:305)
    at org.apache.commons.chain.impl.ChainBase.execute(Ch ainBase.java:191)
    at org.apache.struts.chain.ComposableRequestProcessor .process(ComposableRequestProcessor.java:283)
    at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1913)
    at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:462)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:637)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:286)
    at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:845)
    at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:583)
    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
    at java.lang.Thread.run(Unknown Source)

    plz help me...

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,642
    Rep Power
    7

    Default

    I presume this question is the same as this
    http://www.java-forums.org/database/...exception.html

    To the original poster, some databases have limits on the default transfer sizes. If this is the case then this is a database issue that you should determine based upon the documentation for the database you are using (which is not specified)
    Last edited by doWhile; 02-09-2011 at 03:19 PM.

  4. #4
    tejz is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Default getBinaryStream,getBytes not Working for more than 1MB size

    Code in jap :--

    <%
    try{
    DBConnectionManager dbMgr = new DBConnectionManager();
    Connection con=null;
    con = dbMgr.getConnection();
    ResultSet rs = null;
    // byte[] byt=null;
    String fileName="";
    PreparedStatement psmnt = null;
    // InputStream input1 =null;
    OutputStream outStream = response.getOutputStream();
    String fname=request.getParameter("fname");
    GeneralUtil generalUtil = new GeneralUtil();
    System.out.println("encMId----"+request.getParameter("encMId"));
    String mid = generalUtil.decryptPassword(request.getParameter(" encMId"));
    psmnt = con.prepareStatement("select * from agendadata2 where meetingid=? and filename=?");
    psmnt.setString(1, mid);
    psmnt.setString(2, fname.trim());
    rs = psmnt.executeQuery();
    if(rs.next()) {
    System.out.println("hi i am in next..");
    Blob bl = rs.getBlob("filedata");
    System.out.println("bl.length()----"+bl.length());
    long len = bl.length();
    byte [] byt = bl.getBytes(1, (int) bl.length()); //here above 1MB size not working
    System.out.println("byt----"+byt.length);
    InputStream input1 = new ByteArrayInputStream(byt);
    System.out.println("input1.available()----"+input1.available());
    fileName=rs.getString("filename");
    System.out.println("filename----"+fileName);
    String fileType = fileName.substring(fileName.indexOf(".")+1,fileNam e.length());
    if (fileType.trim().equalsIgnoreCase("txt")) {
    response.setContentType( "text/plain" ); }
    else if (fileType.trim().equalsIgnoreCase("doc"))
    { response.setContentType( "application/msword" );
    }
    else if (fileType.trim().equalsIgnoreCase("xls")) {
    response.setContentType( "application/vnd.ms-excel" );
    }
    else if (fileType.trim().equalsIgnoreCase("pdf"))
    { response.setContentType( "application/pdf" );
    System.out.println("i am in pdf----");
    }
    else
    { response.setContentType( "application/octet-stream" );
    }
    System.out.println("i am in after else----");
    response.setHeader("Cache-Control", "max-age=60");
    response.setContentLength(input1.available());
    response.setHeader("Content-Disposition","attachment; filename="+ fileName);
    response.setHeader("Cache-Control", "no-cache");
    int sizeRead = 0;
    System.out.println("i am in befor while----");
    while ((sizeRead = input1.read(byt, 0, byt.length)) > 0)
    {
    outStream.write(byt, 0, sizeRead);
    }
    input1.close();
    outStream.close();
    }
    } catch ( Exception Se ) {
    Se.printStackTrace();
    }
    out.clear();
    out = pageContext.pushBody();
    %>

  5. #5
    tejz is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Question getBinaryStream,getBytes not Working for more than 1MB size

    DataBase Configaration :---


    DB2 Express-C database server for Windows (32bit)

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    You've been asked before, use code tags, not quote tags.

    Also do not do this in a JSP page. This should be some stand alone code that is called from a Servlet. JSPs are for displaying data.

    As mentioned above, your driver probably has some limitation associated with it which would be documented.

  7. #7
    tejz is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Default

    some databases have limits on the default transfer sizes. If this is the case then this is a database issue that you should determine based upon the documentation for the database you are using (which is not specified).

    ???

    Can u please specify the document name ?

    I am having Admin privileges.

    How to increase the Default Transfer size in the DB2?


    I tried getBinarystream also..It was also giving same Error.


    how to write this code in Servlet ? can please tell process?and how to display it in JSP ?

  8. #8
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    Quote Originally Posted by tejz View Post
    some databases have limits on the default transfer sizes. If this is the case then this is a database issue that you should determine based upon the documentation for the database you are using (which is not specified).

    ???

    Can u please specify the document name ?

    I am having Admin privileges.

    How to increase the Default Transfer size in the DB2?
    That would surely be a question for a DB2 forum, rather than a Java forum.

  9. #9
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    As Tolls says, guys please stick to the forum. This is all about Java, and Database sub-forum not specifically target anything.

    If the discussion moves to a different topic, I've to close this.

  10. #10
    tejz is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Question

    Thanks..Eranga..

    But i am not able to find solution for this error ......


    I searched in the google, but no result..

    please tell me how to increase Default Transfer Size in DB2 ?

  11. #11
    tejz is offline Member
    Join Date
    Feb 2010
    Posts
    10
    Rep Power
    0

    Question

    Hi ,,


    Is we have to increase JVM heap size ?

  12. #12
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,006
    Rep Power
    20

    Default

    It's not going to be anything to do with the Java heap size. That would be an OutOfMemory exception, not a null pointer.

    Find a DB2 forum!

Similar Threads

  1. ResultSet size
    By bugger in forum JDBC
    Replies: 18
    Last Post: 06-25-2011, 08:36 PM
  2. Replies: 3
    Last Post: 02-10-2011, 06:37 AM
  3. Replies: 2
    Last Post: 01-04-2011, 04:30 AM
  4. Setting frame size to the size of an image
    By Yoruichi in forum AWT / Swing
    Replies: 5
    Last Post: 04-22-2009, 04:37 PM
  5. Replies: 8
    Last Post: 05-28-2008, 07:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •