users@glassfish.java.net

Re: java.sql.SQLException: Error in allocating a connection

From: <glassfish_at_javadesktop.org>
Date: Wed, 23 May 2007 20:36:27 PDT

thanks jagdish.
That problem is resolved.One jar file naming-factory-dbcp.jar was missing thats why i was getting that error.

But now i am getting different error for this code(basically i am writng databas connection code)

<%
      Connection con;
      Statement st;
      
      Context ctx = new InitialContext();
         DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/cust");
          
          con = ds.getConnection();
          st=con.createStatement();
          ResultSet rs=st.executeQuery("select * from customer");
          while(rs.next())
          {
           out.println(rs.getString("custName"));
          }
          
    %>


the error i am getting is,

javax.servlet.ServletException: Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
        org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
        org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
        org.apache.jsp.database_jsp._jspService(org.apache.jsp.database_jsp:142)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot load JDBC driver class 'com.microsoft.sqlserver.jdbc.SQLServerDriver'
        org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:766)
        org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
        org.apache.jsp.database_jsp._jspService(org.apache.jsp.database_jsp:116)
        org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
        javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


can u please help me in resolving this?

regards
shruthi
[Message sent by forum member 'shruthifcg' (shruthifcg)]

http://forums.java.net/jive/thread.jspa?messageID=218637