Java.sql.sqlexception No Data Found Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company java no data found exception Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs
Java.sql.sqlexception No Data Found Ms Access
Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, how to catch no data found exception in java just like you, helping each other. Join them; it only takes a minute: Sign up java.sql.SQLException: No data found up vote 4 down vote favorite 1 Its a part of Ajax jsp page while(rs.next()) { System.out.println(rs.getString("Flat_No")); buffer=buffer+""; } There are total 4 values in Flat_No it printing first values in console and aftr that i m getting error on my jsp page "java.sql.SQLException: No data found " java jdbc share|improve this question edited Feb 29 '12 at 18:38 BalusC 684k20924822698 asked Feb 29 '12 at 11:26 Shaggy 1,039115495 add a comment| 1 Answer 1 active oldest votes up vote 11 down vote accepted This is a typical error when using the exception in thread main java.sql.sqlexception no data found MS Access database through the poor JDBC-ODBC bridge driver and retrieving the same data more than once from the result set. You need to retrieve the data once and assign it to a variable and use the variable multiple times instead. while (rs.next()) { String flatNo = rs.getString("Flat_No"); buffer += ""; } Unrelated to the concrete problem, doing this in a JSP file is a bad idea. See also JSP using MVC and JDBC for another concrete example how to do it the proper way. share|improve this answer answered Feb 29 '12 at 18:37 BalusC 684k20924822698 Solved..Thanks..I am also in support for MVC..but my organisation says don't use it as my project business logic is not that big/my project mostly doing DB operations such as INSERT,UPDATE,DELETE –Shaggy Feb 29 '12 at 18:49 1 You're welcome. Be careful with XSS and SQL injection attack holes. –BalusC Feb 29 '12 at 18:50 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers
Java Sql Sqlexception No Data Read
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up java.sql.SQLException: No data found with MS Access database up vote 0 down vote favorite I'm using java with an MS Access database. When I try to search the data in the database I get http://stackoverflow.com/questions/9498231/java-sql-sqlexception-no-data-found this message: java.sql.SQLException: No data found in my database a row is empty, the database looks like this: DATA_TO_READ 1-->string1 2-->string2 3--> 4-->string4 The error message appears when I try to read line 3. I think it's normal because there is no data. This is why I make a verification in order to know if there is some data: while(data.read()) { ExtractString = (data.getString("DATA_TO_READ")!=null) ? data.getString("DATA_TO_READ") : ""; } But even with this verification I still have the same issue. Does http://stackoverflow.com/questions/22822879/java-sql-sqlexception-no-data-found-with-ms-access-database someone have any idea how to solve this issue? java sql database ms-access share|improve this question edited Dec 11 '15 at 23:43 Brian Tompsett - 汤莱恩 3,091132775 asked Apr 2 '14 at 20:57 Kromen 13311 1 PLease show the query. –OldProgrammer Apr 2 '14 at 21:01 maybe writing your instruction inside a `try { ... } catch { ... } block? –Barranka Apr 2 '14 at 21:05 The problem with the try catch block is that it may shadow other SQL exceptions. –aldux Apr 2 '14 at 21:07 I haven't the query because i'm actually not in work, but the query should be something like "SELECT DATA_TO_READ to [my table]". This block is inside a try{} catch{}, when i made "step by step debug" netbean jump to catch when data reading fail, it's why i have "java.sql.SQLException: No data found" error –Kromen Apr 2 '14 at 21:10 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted You try to read the value of a column multiple times.Change the code like that : while(data.read()) { String val = data.getString("DATA_TO_READ"); ExtractString = (val !=null) ? val : ""; } share|improve this answer answered Apr 2 '14 at 21:16 Stathis Andronikos 7581929 It works. Thank you. –Kromen Apr 3 '14 at 7:08 add a comment| Your Answer draft saved draft discarded Sign up or log in
details. Win a copy of Penetration Testing Basics this week in the Security forum! Post Reply Bookmark Topic Watch Topic New Topic programming forums Java Java https://coderanch.com/t/434028/JDBC/databases/java-sql-SQLException-data-read JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site http://www.ibm.com/support/docview.wss?uid=swg21480480 Careers Other all forums Forum: JDBC and Relational Databases java.sql.SQLException: No data read vas reddy Greenhorn Posts: 23 posted 7 years ago Hi, I am getting "java.sql.SQLException: No data read" when I run the following code. but when I used ResultSet rs = stmt.executeQuery(); (the commented line no data in the code) I do n't get any error. Can any one please explain the reason for this? (The query is not returning any rows from DB, rs is not null in both the cases. ResultSet rs = stmt.getResultSet(); or ResultSet rs = stmt.executeQuery(); ) con = ConnectionMain.getDbConnection(); CallableStatement cstmt = con.prepareCall("{ call XXXX(?, ?, ?) no data found }"); cstmt.setString(1, set1); cstmt.setString(2, set2); cstmt.registerOutParameter(3, Types.VARCHAR); cstmt.execute(); app = cstmt.getString(3); if (app == null || app.length()==0) { PreparedStatement stmt = con.prepareStatement(query); stmt.setString(1, app_num); ResultSet rs = stmt.getResultSet(); //ResultSet rs = stmt.executeQuery(); if (rs.next()) { app = rs.getString(1); } stmt.close(); rs.close(); }
thanks vas reddy Greenhorn Posts: 23 posted 7 years ago I found the reason execute the query before getting the resultset. either you use stmt.executeQuery(); ResultSet rs=stmt.getResultSet(); or ResultSet rs = stmt.executeQuery(); Jeanne Boyarsky author & internet detective Marshal Posts: 35052 380 I like... posted 7 years ago Vas, Thanks for sharing the solution for others who have the same problem! [OCA 8 book] [OCP 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos] Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2 Post Reply Bookmark Topic Watch Topic New Topic Similar Threads Couldn't retreive a String from the result set calling stored proc. w/ resultset return? java stored procedure problems Problem when Retreiving from DataBase SQLExceptio
when trying to open a Microsoft Access database from SPSS Text Analysis for Surveys. Technote (troubleshooting) Problem(Abstract) I am using SPSS Text Analysis for Surveys (STAfS). I receive an error stating "java.sql.SQLException: No data found" when trying to open a Microsoft Access database from STAfS. Specifically, I choose File->Import->ODBC. In the resulting dialog box, I choose "MS Access Database" and click next. I then receive the error message. What is wrong? Resolving the problem If you try to set up the data source from within SPSS Text Analysis for Surveys (STAfS) by using the generic access driver that is not already set up for a specific .mdb file, you will receive the error mentioned (no data). In other words, if you choose File->Import->ODBC, and the choose the "MS Access Database" DSN, it will fail. However, if you use the ODBC Data Source Administrator to set up the DSN before hand, then you should be able to import the data without a problem. You can access the ODBC Data Source Administrator by clicking the ODBC button in the Select ODBC Data Source dialog box that comes up when you choose File->Import->ODBC. To set up an Access database in the ODBC Data Source Administrator follow the procedure below: 1) Choose either the User DSN (visible only to the currently logged in account) or System DSN (visible to any account that logs in to this computer) tab and click the Add button. 2) Choose the "Microsoft Access Driver (*.mdb)" driver and click finish. 3) In the ODBC Microsoft Access Setup dialog, enter a name for the data source and an optional description. 4) Click the select button, find the mdb file and select it, then click OK. 5) Click OK in the ODBC Microsoft Access Setup dialog. 6) Finally, click Apply if it is available, then OK in the ODBC Data Source Administrator. You should now see the data source you created in the Select ODBC Data Source dialog box. Select your newly created data source and click next. You can then select the table or write a SQL query and click next. Finally, assign the Unique ID variable, Open Ended Text variable and any Reference variables and click next. Your data should now be displayed in the Text Analysis view Historical Number 50889 Document information More support for: SPSS Text Analytics for Surveys Software version: Not Applicable Operating