![]() |
database in jsp plzz help..!!
Iam new to jsp and trying to make connection with database in jsp iam using the following code :
Code:
<%type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: An exception occurred processing JSP page /DB.jsp at line 43 40: catch(Exception ex) 41: { 42: //out.println("Unable to load the driver class!"+ ex); 43: con.close(); 44: } 45: 46: Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handle JspException(JspServletWrapper.java:505) org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:416) org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet .java:717) root cause java.lang.NullPointerException org.apache.jsp.DB_jsp._jspService(DB_jsp.java:96) org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet .java:717) org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:374) org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet .java:717) note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs. I will be thankful to all of you if you help me and edit my codeto perfection plzz help..!!! |
Re: database in jsp plzz help..!!
yah i got ur problem...in jsp u have to use "PreparedStatement" alwayz instead of only "statement"..i m sending u a sample program..try to understand this...
http://rapidshare.com/files/329297343/jsp.rar.html one more thing..before understanding the above code make sure that u know about the "Statement", "PreparedStatement" i.e u shud have complete knowledge about JDBC |
Re: database in jsp plzz help..!!
this thread should appear in jsp forum.
One cause that I think might be that the code is unable to make the connection to the database and going into catch block, and you are giving the command to close the connection. Do this: make the if condition before closing the database connection, that only if the connection is open close the con. |
Re: database in jsp plzz help..!!
Quote:
|
Re: database in jsp plzz help..!!
Quote:
|
Re: database in jsp plzz help..!!
even your point is correct. But I looked on the error desc
|
Re: database in jsp plzz help..!!
did u set the write environment , cuz its realy important , there are things to get the connection right from what ever database you use , u need to set the nessasary path in you system inevironment , and u may need a JDBC files to get you connection done , + you need the drivers for JDBC to connect .
i advice you to use JDeveloper for orcel it helps , oh i forgot to say u need to create a class , and one more thing u need to set the write libraries like J2EE , JSP Runtime , and SQLDriver for connections hope this helps regards alssadi |
| All times are GMT +5.5. The time now is 02:07. |