Page 1 of 2 12 LastLast
Results 1 to 20 of 21
  1. #1
    jttslg is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default SQLException caught:No data found

    i get this error SQLException caught:No data found whenever i run this program ..... plz help
    my os is windows 7 32 bit


    import java.io.*;
    import java.sql.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Access extends HttpServlet{
    public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
    {
    Connection con=null;
    Statement stmt= null;
    ResultSet rs = null;
    res.setContentType("text/html");
    PrintWriter out=res.getWriter();
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:Access");
    stmt=con.createStatement();
    rs=stmt.executeQuery("SELECT Name,Address FROM CUSTOMER");
    out.println("<HTML><HEAD><TITLE>PhoneBook</TITLE></HEAD>");
    out.println("<BODY>");
    out.println("<UL>");
    while (rs.next()){
    out.println("<LI>"+rs.getString("Name")+" " +rs.getString("Address"));
    }
    out.println("</ul>");
    out.println("</body></html>");
    }
    catch(ClassNotFoundException e)
    {
    out.println("Couldn't load database driver:"+e.getMessage());
    }
    catch(SQLException e)
    {
    out.println("SQLException caught:"+ e.getMessage());
    }
    finally{
    try{
    if(con!=null)con.close();
    }
    catch(SQLException e1)
    {
    }

    }
    }
    }

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    1. Use code tags for your code please.
    2. Supply the full exception, with stack trace...to do this you will need to use printStackTrace() in your catch block.

  3. #3
    jttslg is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default java servlet

    i am new to this topic so plz i do not understand the requirements that you have stated.... the program is from a book and i was trying to run it ..... but the sqk exception kept coming back ..... my dsn name is Access and i created a ms access file called CUSTOMER. PLZ HELP.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    Java Code:
    code tags
    Quote me to see them.

    As for the exception, instead of this:
    Java Code:
    catch(SQLException e)
    {
        out.println("SQLException caught:"+ e.getMessage());
    }
    do this:
    Java Code:
    catch(SQLException e)
    {
        e.printStackTrace();
    }
    And I'd consider rejecting any book that did not do that for outputting exception information.

  5. #5
    jttslg is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default servlet error

    i have tried as you said but it showed a blank screen ....

  6. #6
    jttslg is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default

    it would be of great if you could give a sample code that would implement a database in MS Access that will run in Netbeans 6.0 and also the steps as to how i must select the dsn name in windows 7 , etc...........

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,197
    Rep Power
    19

    Default

    You seem to be under a wrong impression. this is a forum, not a code factory.

    Implement the suggestion made by Tools and post the result and you'll surely get help here. Note that spoonfeeding code is not regarded as help.

    db

  8. #8
    jttslg is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default

    your suggestion leaves me with an empty web page.... plz help

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    You probably do get an empty web page, but your server logs will be printing out the exception the servlet has generated. This will tell you what's wrong.

  10. #10
    jttslg is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default

    how do i find the server log pages....

  11. #11
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    With your server?
    I have no idea what server you are using...Tomcat?

  12. #12
    jttslg is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default

    my server is tomcat.... what do i do next?

  13. #13
    jttslg is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default

    it is integrated with the netbeans i am using

  14. #14
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    Then look up the documentation to find out where the log files are stored.
    Besides, when it's running doesn't it output to the Netbeans console?

  15. #15
    dinesh.guntha is offline Member
    Join Date
    May 2011
    Posts
    27
    Rep Power
    0

    Default

    you use the preparedstatment try with this you may get.

  16. #16
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    PreparedStatement will have zero effect here, and is entirely unecessary since the query does not involve a variable WHERE clause.

  17. #17
    jttslg is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default

    this is what the server log says .....


    Using CATALINA_BASE: "C:\Users\joy\.netbeans\6.9\apache-tomcat-6.0.26_base"
    Using CATALINA_HOME: "C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.26"
    Using CATALINA_TMPDIR: "C:\Users\joy\.netbeans\6.9\apache-tomcat-6.0.26_base\temp"
    Using JRE_HOME: "C:\Program Files\Java\jdk1.6.0_17"
    Using CLASSPATH: "C:\Program Files\Apache Software Foundation\Apache Tomcat 6.0.26\bin\bootstrap.jar"
    13 May, 2011 7:53:31 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: Loaded APR based Apache Tomcat Native library 1.1.20.
    13 May, 2011 7:53:31 PM org.apache.catalina.core.AprLifecycleListener init
    INFO: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
    13 May, 2011 7:53:32 PM org.apache.coyote.http11.Http11AprProtocol init
    INFO: Initializing Coyote HTTP/1.1 on http-8084
    13 May, 2011 7:53:32 PM org.apache.coyote.ajp.AjpAprProtocol init
    INFO: Initializing Coyote AJP/1.3 on ajp-8009
    13 May, 2011 7:53:32 PM org.apache.catalina.startup.Catalina load
    INFO: Initialization processed in 1374 ms
    13 May, 2011 7:53:32 PM org.apache.catalina.core.StandardService start
    INFO: Starting service Catalina
    13 May, 2011 7:53:32 PM org.apache.catalina.core.StandardEngine start
    INFO: Starting Servlet Engine: Apache Tomcat/6.0.26
    13 May, 2011 7:53:33 PM org.apache.catalina.startup.HostConfig deployDescriptor
    INFO: Deploying configuration descriptor joy.xml
    13 May, 2011 7:53:34 PM org.apache.struts.action.ActionServlet initChain
    INFO: Loading chain catalog from jar:file:/C:/Users/joy/Documents/NetBeansProjects/joy/build/web/WEB-INF/lib/struts-core-1.3.8.jar!/org/apache/struts/chain/chain-config.xml
    13 May, 2011 7:53:34 PM org.apache.struts.tiles.TilesPlugin initDefinitionsFactory
    INFO: Tiles definition factory loaded for module ''.
    13 May, 2011 7:53:34 PM org.apache.struts.validator.ValidatorPlugIn initResources
    INFO: Loading validation rules file from '/WEB-INF/validator-rules.xml'
    13 May, 2011 7:53:34 PM org.apache.struts.validator.ValidatorPlugIn initResources
    INFO: Loading validation rules file from '/WEB-INF/validation.xml'
    13 May, 2011 7:53:35 PM org.apache.catalina.startup.HostConfig deployDescriptor
    INFO: Deploying configuration descriptor manager.xml
    13 May, 2011 7:53:35 PM org.apache.catalina.startup.HostConfig deployDescriptor
    INFO: Deploying configuration descriptor ROOT.xml
    13 May, 2011 7:53:35 PM org.apache.catalina.startup.HostConfig deployDescriptor
    INFO: Deploying configuration descriptor WebApplication1.xml
    13 May, 2011 7:53:36 PM com.sun.faces.config.ConfigureListener contextInitialized
    INFO: Initializing Sun's JavaServer Faces implementation (1.2_04-b20-p03) for context '/WebApplication1'
    13 May, 2011 7:53:36 PM org.apache.coyote.http11.Http11AprProtocol start
    INFO: Starting Coyote HTTP/1.1 on http-8084
    13 May, 2011 7:53:36 PM org.apache.coyote.ajp.AjpAprProtocol start
    INFO: Starting Coyote AJP/1.3 on ajp-8009
    13 May, 2011 7:53:36 PM org.apache.catalina.startup.Catalina start
    INFO: Server startup in 3671 ms
    java.sql.SQLException: No data found
    at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java :7138)
    at sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(JdbcOdbc.j ava:3073)
    at sun.jdbc.odbc.JdbcOdbcConnection.initialize(JdbcOd bcConnection.java:323)
    at sun.jdbc.odbc.JdbcOdbcDriver.connect(JdbcOdbcDrive r.java:174)
    at java.sql.DriverManager.getConnection(DriverManager .java:582)
    at java.sql.DriverManager.getConnection(DriverManager .java:207)
    at Access.doGet(Access.java:15)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:617)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:717)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:393)
    at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:102)
    at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:298)
    at org.apache.coyote.http11.Http11AprProcessor.proces s(Http11AprProcessor.java:859)
    at org.apache.coyote.http11.Http11AprProtocol$Http11C onnectionHandler.process(Http11AprProtocol.java:57 9)
    at org.apache.tomcat.util.net.AprEndpoint$Worker.run( AprEndpoint.java:1555)
    at java.lang.Thread.run(Thread.java:619)

  18. #18
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    There's your error then:
    java.sql.SQLException: No data found
    ...
    at Access.doGet(Access.java:15)

    So, which line is line 15?

  19. #19
    jttslg is offline Member
    Join Date
    Mar 2010
    Posts
    26
    Rep Power
    0

    Default

    i believe this is line 15

    con = DriverManager.getConnection("jdbc:odbc:Access");

  20. #20
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,949
    Rep Power
    19

    Default

    I'm pretty sure a No Data Found does not come from a getConnection().
    It usually comes from the result set.

    So, check you are running the code you think you are running (recompile and redeploy)...to ensure that's the case stick in some debug code (System.out.println()) which should go to your logs...or use a proper logger.

Page 1 of 2 12 LastLast

Similar Threads

  1. SQLException caught:No data found
    By jttslg in forum NetBeans
    Replies: 0
    Last Post: 04-20-2011, 04:07 PM
  2. SQLException caught: Communications link failure due to underlying exception: **
    By sharanya in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 02-25-2011, 09:46 AM
  3. Replies: 3
    Last Post: 02-18-2011, 11:31 AM
  4. Replies: 6
    Last Post: 02-21-2010, 12:54 AM
  5. data.txt not found
    By RedSix in forum Eclipse
    Replies: 4
    Last Post: 04-23-2009, 02:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •