Solved

Insert Data to Oracle Database through Servlet

Posted on 2000-04-20
5
321 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
Comment Utility
can you post some code?
0
 
LVL 2

Expert Comment

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

Expert Comment

by:heyhey_
Comment Utility
tell us what's on line 62 inside
RegistrationServlet.java

:)
0
 
LVL 3

Expert Comment

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

Rajiv
0
 

Accepted Solution

by:
bimpf earned 50 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
pairstar challenge 2 41
strCopies  challenge 17 73
Python Assistance 7 31
eclipse compiler vs Installed JREs option 3 37
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

743 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

16 Experts available now in Live!

Get 1:1 Help Now