You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Kumar Abhay-CAK203C <CA...@motorola.com> on 2004/04/06 20:01:12 UTC

[OT] getBlob() error in Tomcat

Hi,

Any idea why this error is coming in runtime?

Servlet) - FileDisplayServlet.doPost()
java.lang.AbstractMethodError: oracle.jdbc.driver.OracleResultSetImpl.getBlob(Ljava/lang/String;)Ljava/sql/Blob;
        at org.apache.commons.dbcp.DelegatingResultSet.getBlob(DelegatingResultSet.java:318)
        at com.mot.iDEN.webapp.oes.servlet.FileDisplayServlet.readBlob(FileDisplayServlet.java:169)

I am trying to display a image that is stored in a BLOB field in Oracle. I am using connection pooling and classes12.jar

Servlet Code 
----------------------------------------------------------------------------------------------------------------------------------------------------------------
	private void readBlob
				(
					HttpServletRequest request,
					HttpServletResponse response,
					long aFeatureId,
					String aFileName,
					String aUserId
				)
		throws SQLException,IOException
	{
		Connection conn = null;
		ResultSet result = null;
		PreparedStatement prepStmt = null;
		java.io.InputStream in = null;
		java.sql.Blob myBlob = null;
		FileUploadFactory uploadFactory = new FileUploadFactory();

		try
		{
			conn = config_.getEstimationConnection(false);
			String sql = "";
			sql =
				"	SELECT "+
				"		FILE_IMAGE "+
				"	FROM "+
				"		OES_FEATURE_DETAILS "+
				"	WHERE "+
				"		FEATURE_ID = "+aFeatureId;

			log_.debug("SQL:==="+sql);
			log_.debug("result=" + result);
			prepStmt = conn.prepareStatement(sql);
			result = prepStmt.executeQuery();
			if (result != null && result.next())
			{
				//get the file ext
				String strDocExt = "";
				try
				{
					strDocExt = uploadFactory.getFileType(aFileName, aUserId);
				}
				catch(Exception e)
				{
					log_.debug("Exception is"+e);
				}
				//get the file length
				int intCountBytes = 0;
				String strPrpValue = null;
				//set the mimetype
				ResourceBundle mimetype = ResourceBundle.getBundle("mimes");
				strPrpValue = mimetype.getString(strDocExt.toLowerCase());
				log_.debug("Value=" + strPrpValue);
				if (strPrpValue != null)
				{
					response.setContentType(strPrpValue);
					response.setHeader("Content-Disposition", "inline; filename=" + aFileName);
				}
				myBlob = result.getBlob("FILE_IMAGE");
				//get the inputStream
				in = myBlob.getBinaryStream();
				/*Get the Output Stream*/
				if (in != null)
				{
					generatePresentation(in, response);
					in.close();
				}
        	}
		}
		catch (SQLException sqle)
		{
			throw new SQLException("FileDisplayServlet.readBlob", "" + sqle.getErrorCode());
		}
		catch (IOException io)
				{
					throw new IOException("FileDisplayServlet.readBlob");
		}
		finally
		{
			try
			{
				if (result != null)
				{
		  			result.close();
				}
				if (prepStmt != null)
				{
		  			prepStmt.close();
				}
				if (conn != null)
				{
		  			conn.close();
				}
			}
			catch (SQLException sqle)
			{
				throw new SQLException("FileDisplayServlet.readBlob");
			}
		}
	}
------------------------------------------------------------------------------------------------------------------------------------------------------------

Best Regards
Abhay Kumar