Results 1 to 12 of 12
- 02-09-2011, 10:09 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 10
- Rep Power
- 0
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...
- 02-09-2011, 12:41 PM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Could you please show us what you've done so far?
- 02-09-2011, 03:16 PM #3
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,609
- Rep Power
- 5
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.
- 02-09-2011, 03:51 PM #4
Member
- Join Date
- Feb 2010
- Posts
- 10
- Rep Power
- 0
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();
%>
- 02-09-2011, 03:52 PM #5
Member
- Join Date
- Feb 2010
- Posts
- 10
- Rep Power
- 0
getBinaryStream,getBytes not Working for more than 1MB size
DataBase Configaration :---
DB2 Express-C database server for Windows (32bit)
- 02-10-2011, 06:41 AM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
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.
- 02-10-2011, 02:26 PM #7
Member
- Join Date
- Feb 2010
- Posts
- 10
- Rep Power
- 0
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 ?
- 02-10-2011, 02:48 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
- 02-15-2011, 01:15 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
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.
- 02-15-2011, 03:42 PM #10
Member
- Join Date
- Feb 2010
- Posts
- 10
- Rep Power
- 0
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 ?
- 02-17-2011, 07:06 AM #11
Member
- Join Date
- Feb 2010
- Posts
- 10
- Rep Power
- 0
Hi ,,
Is we have to increase JVM heap size ?
- 02-17-2011, 08:15 AM #12
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
ResultSet size
By bugger in forum JDBCReplies: 18Last Post: 06-25-2011, 08:36 PM -
blob.getBytes(1, (int) bl.length()); gives Nullpointer Exception
By tejz in forum JDBCReplies: 3Last Post: 02-10-2011, 06:37 AM -
\n not working in GUI (working code, but \n isn't working)
By cc11rocks in forum New To JavaReplies: 2Last Post: 01-04-2011, 04:30 AM -
Setting frame size to the size of an image
By Yoruichi in forum AWT / SwingReplies: 5Last Post: 04-22-2009, 04:37 PM -
Java mail problem(working in intranet,but not working in iternet)
By sundarjothi in forum Advanced JavaReplies: 8Last Post: 05-28-2008, 07:00 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks