Solved

Insert Data to Oracle Database through Servlet

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Unable to open debugger port in Intellij idea 6 139
Requested array size exceeds VM limit 3 84
oracle 11g 23 46
expectj telnet failing 5 17
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

930 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now