Error Java.sql.sqlexception No Data Found
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 Business Learn
Java.sql.sqlexception No Data Found Ms Access
more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags java no data found exception Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, how to catch no data found exception in java 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
Exception Java.sql.sqlexception No Data Found
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 683k20824732692 asked Feb 29 '12 at 11:26 Shaggy 1,039115394 add a comment| 1 Answer 1 active oldest votes up vote 11 down vote accepted This is a typical error when using the 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 683k20824732692 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 you're looking for? Browse other questions tagged java jdbc or a
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 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 http://stackoverflow.com/questions/9498231/java-sql-sqlexception-no-data-found 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 while inserting the data into table up vote 0 down vote favorite I am trying to inserting the data into the table using ms access 2007 but http://stackoverflow.com/questions/16012965/java-sql-sqlexception-no-data-found-while-inserting-the-data-into-table getting the exception "java.sql.SqlException: no data found" My data souce name is employee import java.sql.*; class AccessDatabase { public static void main(String[] args) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con = DriverManager.getConnection ("jdbc:odbc:employee"); Statement st = con.createStatement(); String name = "roseindia"; String address = "delhi"; int i = st.executeUpdate("insert into user(name,address) values ('" + name + "','" + address + "')"); System.out.println("Row is added"); } catch (Exception e) { System.out.println(e); } } } java swing ms-access odbc share|improve this question edited Apr 15 '13 at 10:49 asked Apr 15 '13 at 10:30 user1782870 add a comment| 1 Answer 1 active oldest votes up vote 0 down vote accepted I think you don't have a database created. Following code should work: import java.sql.*; class ExecuteSqlQuery { public static void main(String[] args) { try { Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root"); Statement st=con.createStatement(); String str = "CREATE TABLE user(id INTEGER, " + "name VARCHAR(25), address VARCHAR(100), primary key(id))"
here for a quick overview of the site Help Center Detailed answers to any questions you might have http://stackoverflow.com/questions/30022058/getting-severe-null-java-sql-sqlexception-no-data-found-error Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with https://coderanch.com/t/304262/JDBC/databases/java-sql-SQLException-data 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 no data like you, helping each other. Join them; it only takes a minute: Sign up Getting SEVERE: null java.sql.SQLException: No data found error up vote 0 down vote favorite I am trying to store the DB value into two different array. if test_type is ”New”=> store first array, else=> second array. Am getting “SEVERE: null java.sql.SQLException: No no data found data found error” while assign rs.getString value to variable\array. Could anyone help me to solve the issue? Am using MS access as DB code: try { DatabaseConnectivity(); stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,ResultSet.CONCUR_READ_ONLY); String select="Select * from (SELECT DISTINCT test_name,test_type FROM ScenarioTable)order by test_type "; ResultSet rs = stmt.executeQuery(select); String colvalues; String print="null"; int arycount=1; basicarray=new String [20][20]; newarray=new String [20][20]; while (rs.next()) { print=rs.getString(1); if (print.equals("New")) { for(int itration=1;itration<=2;itration++) { colvalues=rs.getString(itration); newarray[arycount][itration]=colvalues; } } else { for(int itration=1;itration<=2;itration++) { colvalues=rs.getString(itration); basicarray[arycount][itration]=colvalues; } arycount++; } error: Connection Successful May 04, 2015 8:26:37 AM NewJFrame btn_refreshActionPerformed SEVERE: null java.sql.SQLException: No data found at sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7145) at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(JdbcOdbc.java:3914) at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(JdbcOdbcResultSet.java:5697) at sun.jdbc.odbc.JdbcOdbcResultSet.getString(JdbcOdbcResultSet.java:353) at NewJFrame.btn_refreshActionPerformed(NewJFrame.java:1140) at NewJFrame.access$1800(NewJFrame.java:47) at NewJFrame$21.actionPerformed(NewJFrame.java:734) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018) java sql sqlexception share|improve this question edited May 4 '15 at 3:15 AVD 71.8k1489139 asked May 4 '15 at 3:12 sathish kumar 194 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote The same data should not be retrieved more than once from the result set. Namely, be
This Site Careers Other all forums Forum: JDBC and Relational Databases java.sql.SQLException: no data found Rafael Fagundes Ranch Hand Posts: 52 posted 10 years ago Hi! Well, the source code: ....... while (rs.next()) { ResultSetMetaData meta = rs.getMetaData(); int count = meta.getColumnCount(); Map elemento = new HashMap(); for (int i = 0; i < count; i++) { Object o = null; if (rs.getObject(i + 1) == null) { o = ""; } else { o = rs.getObject(i + 1); // ERROR LINE } ....... At the error line, the java.sql.SQLException: no data found is throwed. I can�t understand the reason..... When I try this: ...... } else { System.out.println("\n\n cod "+rs.getString(1)); o = rs.getObject(i + 1); ...... The data is normally printed...... but the exception is throwed any way. Extra iformation: sun.jdbc.odbc.JdbcOdbcDriver MySQL 5 JDK 1.5 Doe�s somebody can help? Thank�s in advance, Rafael. Thanks, Rafa Vallidevi Appana Greenhorn Posts: 25 posted 10 years ago Hi Try this out..... while (rs.next()) { ResultSetMetaData meta = rs.getMetaData(); int count = meta.getColumnCount(); Map elemento = new HashMap(); for (int i = 0; i < count; i++) { Object o = rs.getObject(i + 1); if (o == null) { o = ""; } Problem might be calling getObject twice.... stu derby Ranch Hand Posts: 333 posted 10 years ago Extra iformation: sun.jdbc.odbc.JdbcOdbcDriver MySQL 5 JDK 1.5 I think the other poster is correct, that the 2nd call to getObject for the same column is the problem. Some drivers allow that and some don't (the JDBC allows this difference). In particular, I think the native MySQL driver will allow it and the JDBC-ODBC bridge that you're using won't. Rafael Fagundes Ranch Hand Posts: 52 posted 10 years ago Thank�s Vallidevi. You was completle write. Stu derby, you are write also. On the first version of the application, I was using the native MySQL driver. There was no problem with the posted code. When I changed de driver for sun.jdbc.odbc.JdbcOdbcDriver, this problem started to happen (not because it�s a bad driver, off course; it simply dosen�t support what I was trying to do). Thank�s all for the attent