Solved

Insert Data to Oracle Database through Servlet

Posted on 2000-04-20
5
325 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
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 50 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
eclipse argument 14 60
difference of if loops 23 49
reverse digits of a number using for loop 5 40
How to determine if a string is a valid SHA value 7 28
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…

805 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