I am getting java.lang.nullpointer exception for this code plzz help me out all database linked programs are creating same error

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.sql.*;

public class retser extends HttpServlet {
    Connection c;
    Statement st;
    ResultSet rs;
    ServletConfig config;

    public void init() {
        config = getServletConfig();
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            c = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE", "system", "tiger");
            Statement st = c.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
            rs = st.executeQuery("select * from book");
        } catch (Exception e) {
        }
    }//end init

    public void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
        PrintWriter pw = res.getWriter();
        try {
            int x = Integer.parseInt(req.getParameter("t1"));
            pw.println(x);
            rs.next();
            pw.println(rs.getInt(1));
//+"  "+rs.getString(2)+"  "+rs.getInt(3)		
        } catch (Exception e) {
            pw.println(e);
        }
    }
}

and what are you getting a nullpointer on? since we don't have your complete code, nor access to the resources you are using, you don't think we'll be able to reproduce your error, do you?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.