简体   繁体   中英

How to get the value in a specific row one by one

I don't know how should I explain this but what I had in mind is to get a value in a row then get the others all the way down.

So I've already made some code to help me on this but I can't figure out what to do next. Here:

try{
    String url = "jdbc:mysql://localhost:3306/processingdb"; 
    Connection conn = DriverManager.getConnection(url,"rootche","sandy"); 
    Statement st = conn.createStatement();
    rst =st.executeQuery("SET @t1=0;");
    rs = st.executeQuery("SELECT @t1 := @t1+1 as row_number, processtble.* from processtble ORDER      BY ArrivalTime ASC LIMIT 10");

    //jTable1.setModel(DbUtils.resultSetToTableModel(rs));


    conn.close();
 } 
   catch (Exception e) { 
        System.err.println("Got an exception! "); 
        JOptionPane.showMessageDialog(null,"Got an exception!");
        System.err.println(e.getMessage()); 
 }

So I have already sorted the values based on the ArrivalTime which contains different numbers from 1-10 (milliseconds) and made another column, 'row_number', to identify which will go first.

I want to get the value on the ArrivalTime one by one so that I can use it on a computation. I have already tried some measures but I always get the bottom of the list.

Hope someone can help me.

 while (rs.next()) {
    // Read a row here
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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