Solved

Insert Data to Oracle Database through Servlet

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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
fibonacci ten numbers 4 45
Can anyone please tell me why i can not find ID  investorCoolGrid inside the jsp page? 1 22
mysql jsp example issue 32 48
Setup GlassFish 4 21
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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:
This video teaches viewers about errors in exception handling.

856 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