【问题标题】:Jtable and MySqlJtable 和 MySql
【发布时间】:2013-03-10 04:59:47
【问题描述】:

当我尝试执行以下编码时,我遇到了错误。我无法理解这个 netbeans 错误。错误如下。

Mar 21, 2013 2:28:19 AM timetable.generator.JFTTGenerator6 jButton2ActionPerformed
SEVERE: null
java.sql.SQLException: Before start of result set
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)

请帮帮我!!!!

String subj=(String) jTable1.getValueAt(0,1 );
Connection con = Driver.connect();
ResultSet lec1=Handler.getData(con,
"select lec_id from lecdetails,subjects where subjects.sub_code=lecdetails.sub_code 
 and subjects.sub_name='"+subj+"'");
ResultSet rst1= Handler.getData(con, "select sub_name from subjects,lecdetails 
where subjects.sub_code=lecdetails.sub_code and subjects.sem='2nd' and 
lecdetails.lec_id  <> '"+lec1.getString(1) +"' order by rand() limit 1 ");
jTable2.setValueAt(lec1.getString(1), 0, 1);

【问题讨论】:

    标签: java mysql swing jtable resultset


    【解决方案1】:

    在使用lec.getString(1)之前,您必须先致电next()

    所以,在声明之前 ResultSet rst1= Handler.getData,

    添加

    if (lec1.next()){
        //second result set statement.
        //set value in jtable
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-06
      • 1970-01-01
      • 2013-09-25
      相关资源
      最近更新 更多