GeeCON Prague 2014*
The moose likes JDBC and the fly likes Error while jsp connecting to database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "Error while jsp connecting to database" Watch "Error while jsp connecting to database" New topic
Author

Error while jsp connecting to database

Anuragk kushwaha
Ranch Hand

Joined: Aug 02, 2006
Posts: 51
hi all,
i am in problem please help me.

i write a jsp to connect to the sql server 2000 database using microsoft sqlserver driver for jdbc sp3(type 4 driver).while running the following errors occured.i think driver is loaded successfully but not connected to the database. i have set all necessary classpath for driver.

please help me soon!!!

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: com.microsoft.jdbc.sqlserver.SqlServerDriver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.FromDb_jsp._jspService(FromDb_jsp.java:114)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
org.apache.jsp.LoginValidate_jsp._jspService(LoginValidate_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SqlServerDriver
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1340)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1189)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:150)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:71)
java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
java.lang.Class.forName0(Native Method)
java.lang.Class.forName(Class.java:164)
org.apache.jsp.FromDb_jsp._jspService(FromDb_jsp.java:55)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
org.apache.jsp.LoginValidate_jsp._jspService(LoginValidate_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.30
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

i think driver is loaded successfully but not connected to the database.

No it is not loaded at all because it is not found. Where did you put the driver ? You should put it in WEB-INF/lib


[My Blog]
All roads lead to JavaRanch
Anuragk kushwaha
Ranch Hand

Joined: Aug 02, 2006
Posts: 51
thanks for reply,
afetr putting all the jar files in lib folder.the same errors ocuurs
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

I think that the driver class is not correct (uppercases) :
Try with com.microsoft.jdbc.sqlserver.SQLServerDriver
Anuragk kushwaha
Ranch Hand

Joined: Aug 02, 2006
Posts: 51
hi satou,
after applying your suggetions .
now the errors...

HTTP Status 500 -

--------------------------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: No suitable driver
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:846)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.FromDb_jsp._jspService(FromDb_jsp.java:114)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
org.apache.jsp.LoginValidate_jsp._jspService(LoginValidate_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.sql.SQLException: No suitable driver
java.sql.DriverManager.getConnection(DriverManager.java:545)
java.sql.DriverManager.getConnection(DriverManager.java:193)
org.apache.jsp.FromDb_jsp._jspService(FromDb_jsp.java:56)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary.java:966)
org.apache.jsp.LoginValidate_jsp._jspService(LoginValidate_jsp.java:84)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.30
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Maybe you're using a wrong URL. Please post it using dummy connection parameters.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

By the way, there is also JDBC forum where you can post that kind of questions:
http://www.coderanch.com/forums/f-3/JDBC

And maybe you should read the FAQ about JDBC connection issues:
http://faq.javaranch.com/view?JdbcConnectionQuestions
 
GeeCON Prague 2014
 
subject: Error while jsp connecting to database