简体   繁体   English

严重:null java.sql.SQLException:找不到数据错误

[英]Getting SEVERE: null java.sql.SQLException: No data found error

I am trying to store the DB value into two different array. 我正在尝试将数据库值存储到两个不同的数组中。 if test_type is ”New”=> store first array, else=> second array. 如果test_type为“ New” =>存储第一个数组,否则=>存储第二个数组。 Am getting “SEVERE: null java.sql.SQLException: No data found error” while assign rs.getString value to variable\\array. 将rs.getString值分配给variable \\ array时,出现“严重:null java.sql.SQLException:找不到数据错误”。 Could anyone help me to solve the issue? 有人可以帮我解决问题吗? Am using MS access as DB 我正在使用MS Access作为数据库

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)

The same data should not be retrieved more than once from the result set. 从结果集中检索相同的数据不应超过一次。
Namely, because rs.getString(1) was executed twice, the exception was thrown. 即,因为rs.getString(1)被执行了两次,所以引发了异常。
Use another variable to keep the value of rs.getString(1) 使用另一个变量保留rs.getString(1)的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM