?
Solved

Insert Data to Oracle Database through Servlet

Posted on 2000-04-20
5
Medium Priority
?
340 Views
Last Modified: 2013-11-24
I want to Insert data to Oracle Database through Servlet. But I am My code is correct while compiling it is not giving any error while run i am getting this error

Error. The server encountered an unexpected condition which prevented it from fulfilling the request.


java.lang.NullPointerException:
      at RegistrationServlet.destroy(RegistrationServlet.java:62)
      at newatlanta.servletexec.ServletExec.CallServletDestroy(ServletExec.java)
      at newatlanta.servletexec.HostServletContext.loadServlet(HostServletContext.java)
      at newatlanta.servletexec.HostServletContext.getServlet(HostServletContext.java, Compiled Code)
      at newatlanta.servletexec.ServletExec.processServletRequest(ServletExec.java, Compiled Code)
      at newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java, Compiled Code)
      at newatlanta.servletexec.ServletExec.ProcessRequest(ServletExec.java, Compiled Code)

Please Help me it is urgent
0
Comment
Question by:bhagyakitty
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Expert Comment

by:ovidiucraciun
ID: 2734060
can you post some code?
0
 
LVL 2

Expert Comment

by:azawawi
ID: 2734488
and tell us about the environment you're using also...
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 2734570
tell us what's on line 62 inside
RegistrationServlet.java

:)
0
 
LVL 3

Expert Comment

by:terajiv
ID: 2736839
Hi bhagyakitty,
Just check whether ODBC connection is proper.. using ODBC32...

Rajiv
0
 

Accepted Solution

by:
bimpf earned 100 total points
ID: 2738770
I had the same problem when writing servlets that where acessing a class with DBOperations.

I don't know how your program is designed ... but in my case i had one centralized class for DB-Operations, which was accessed through different servlets.

My fault was that I was trying to load the oracle-db-class and creating the db-connection within the DB-Class and not within the servlet  - the problem's solution was to load class-driver and to create db-connection within the servlet and pass it to the db-class.


..... here some code-snipples:

---- init() - method of servlet: ----
Connection dbCon;
public void init() throws ServletException(){
[....]
            try{
                  Class.forName(act_dbclass);
                  dbCon = DriverManager.getConnection(act_dbconnection,act_dbusern,act_dbpassw);
            }
            catch (ClassNotFoundException e){
                  System.out.println("ClassNotFoundException in Template!");
            }
            catch (SQLException e){
                  System.out.println("SQLException in Template!");
            }
            }

DBOperation myDBOperation = new DBOperation(dbCon);

}



--- destroy() - method -----
      public void destroy(){
            try{
                  dbCon.close();
                  System.out.println("verbindung geschlossen");
            }
            catch (Exception e){
                  System.out.println("DB close failed in Template");
            }
      }
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
A solution for Fortify Path Manipulation.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses
Course of the Month9 days, 13 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question