Results 1 to 2 of 2
  1. #1
    nitishjtm is offline Member
    Join Date
    Sep 2010
    Posts
    30
    Rep Power
    0

    Post AbstractMethodError

    Hi, I have written the following servlet:

    Java Code:
    package com.nitish.servlets;
    import javax.servlet.*;
    import java.io.*;
    import java.sql.*;
    import javax.sql.*;
    import oracle.sql.*;
    
    public class RequestServlet extends GenericServlet{
    	public void init(ServletConfig sc)throws ServletException{
    		try{
    			Class.forName("oracle.jdbc.driver.OracleDriver");
    		}//try
    		catch(Exception e){
    			throw new ServletException("Unable to load the driver");
    		}//catch
    	}//init
    	public void service(ServletRequest req,ServletResponse res)throws ServletException,IOException{
    		String name=req.getParameter("name");
    		String college=req.getParameter("college");
    		String university=req.getParameter("university");
    		String contactno=req.getParameter("contactno");
    		String[] course=req.getParameterValues("Course");
    		String photo=req.getParameter("photo");
    		byte []b=photo.getBytes();
    		//ByteArrayInputStream bis=new ByteArrayInputStream(b);
    		Blob b1=new SerialBlob(b);
    		PrintWriter out =res.getWriter();
    		Connection con=null;
    		PreparedStatement ps=null;
            try{
    			con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","nitish");
    			ps=con.prepareStatement("insert into stenquiry values(?,?,?,?,?)");
    			ps.setString(1,name);
    			ps.setString(2,college);
    			ps.setString(3,university);
    			ps.setString(4,contactno);
    			ArrayDescriptor ad=ArrayDescriptor.createDescriptor("COURSEARRAY",con);
    			ARRAY a=new ARRAY(ad,con,course);
    			ps.setArray(5,a);
    			ps.setBlob(6,b1);
    			//ps.setBlob(6,bis);
                            ps.executeUpdate();
    			out.println("Records Inserted Successfully");
    		}//try
    		catch(Exception e){}
    		finally{
    			try{
    				ps.close();
    				con.close();
    			}//try
    			catch(Exception e){
    				e.printStackTrace();
    			}//catch
    		}//finally
    	}//service
    }//class
    The problem I am facing is when I tried to compile the code, it gave me error saying that cannot find symbol:SerialBlob(); , while I have set the classpath for ojdbc14.jar prior to compilation.

    And instead of using blob object in setBlob(), I also tried to use input stream. It compiled successfully, but when I executed the program, it gave me error as follows:

    java.lang.AbstractMethodError: oracle.jdbc.driver.T4CPreparedStatement.setBlob(IL java/io/InputStream;)V
    com.stech.servlets.RequestServlet.service(RequestS ervlet.java:40)
    I am not getting why is this happening.

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

    Default

    You haven't imported SerialBlob.
    Don't rely on using '*' to pick everything up. It's lazy.
    It also doesn't pick up sub-packages.

    Anyway, it should work with the InputStream.
    Show us the code for using the InputStream.

Posting Permissions

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