× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



so, maybe something like this:

DB2400 nal820 = new DB2400();
String timeQuery = new String("select tiatim, tisec2, tisec3, tipc01, 
tipc02, tipc03, tipc04, tipc05, tipc06, tipc07, tipc08, tipc09, tipc10, " 
+
                  "tihr01, tihr02, tihr03, tihr04, tihr05, tihr06, tihr07, 

tihr08, tihr09, tihr10 from timecustom.ktimld4 " +
                  "where tiatim between " + Long.toString(indt1) + " and " 

+ Long.toString(ondt) + " and tisec3 <> 'FH' and tisec3 <> ' ' and tisec2 
not in " +
                  "('01300', '04301', '01306', '01310', '01311', '01319', 
'01320', '01326', '01327', '01328', '01332', '01333', " +
                  "'01334', '01335', '01336', '01401', '01408', '01440', 
'01456', '01706', '01710', '01712', '02302', '02303', " +
                  "'02305', '02307', '02308', '02309', '02313', '02314', 
'02316', '02317', '05325', '02403', '02409', '02441', " +
                  "'02457', '02702', '02714', '06350', '06351', '06352', 
'06353', '06354', '06355', '06356', '06357', '06358', " +
                  "'06359', '06360', '06416', '06422', '06708', '06718') 
order by tisec3, tisec2");
PreparedStatement queryKTIMLD4 = nal820.conn.prepareStatement(timeQuery);
ResultSet rs = queryKTIMLD4.executeQuery();
while (rs.next() == true) {
   tiatim = rs.getLong(1);
   tisec2 = rs.getString(2);
   tisec3 = rs.getString(3);
   for (int j = 0; j <= 9; j++) {
      pc[j] = rs.getString("tipc" + (Integer.toString(j+1)).trim());
   }
   for (int j = 0; j <= 9; j++) {
      hrs[j] = rs.getBigDecimal("tihr" + (Integer.toString(j+1)).trim());
   }
   for (x = 0; x <= 9; x++) {
      workCodeQuery = "select wcnonw from clocfile01.ckworkcd where wccode 

= '" + pc[x].trim() + "'";
      queryKTIMLD4.close();   // like this???
      PreparedStatement queryCKWORKCD = 
nal820.conn.prepareStatement(workCodeQuery);
      ResultSet rs2 = queryCKWORKCD.executeQuery();
      wcnonw = rs2.getString(1);
      // further processing...
   }
   rs2.close();
   queryCKWORKCD.close();
}
rs.close();
queryKTIMLD4.close();

Shane Cessna  
iSeries Programmer
iSeries WAS Administrator
North American Lighting, Inc.
(618) 662-4483 x2776
shane_cessna@xxxxxxx 



Franco Biaggi <fbiaggi@xxxxxxxxxx> 
Sent by: java400-l-bounces@xxxxxxxxxxxx
06/16/2005 09:58 AM
Please respond to
Java Programming on and around the iSeries / AS400 
<java400-l@xxxxxxxxxxxx>


To
Java Programming on and around the iSeries / AS400 
<java400-l@xxxxxxxxxxxx>
cc

Subject
Re: JDBC question...






Hi,
maybe you should close the statement.
No need to use prepared statements in this case,
all the statements are fixed.

Shane_Cessna@xxxxxxx wrote:

>DB2400 nal820 = new DB2400();
>String timeQuery = new String("select tiatim, tisec2, tisec3, tipc01, 
>tipc02, tipc03, tipc04, tipc05, tipc06, tipc07, tipc08, tipc09, tipc10, " 

>+
>                  "tihr01, tihr02, tihr03, tihr04, tihr05, tihr06, 
tihr07, 
>tihr08, tihr09, tihr10 from timecustom.ktimld4 " +
>                  "where tiatim between " + Long.toString(indt1) + " and 
" 
>+ Long.toString(ondt) + " and tisec3 <> 'FH' and tisec3 <> ' ' and tisec2 

>not in " +
>                  "('01300', '04301', '01306', '01310', '01311', '01319', 

>'01320', '01326', '01327', '01328', '01332', '01333', " +
>                  "'01334', '01335', '01336', '01401', '01408', '01440', 
>'01456', '01706', '01710', '01712', '02302', '02303', " +
>                  "'02305', '02307', '02308', '02309', '02313', '02314', 
>'02316', '02317', '05325', '02403', '02409', '02441', " +
>                  "'02457', '02702', '02714', '06350', '06351', '06352', 
>'06353', '06354', '06355', '06356', '06357', '06358', " +
>                  "'06359', '06360', '06416', '06422', '06708', '06718') 
>order by tisec3, tisec2");
>PreparedStatement queryKTIMLD4 = nal820.conn.prepareStatement(timeQuery);
>ResultSet rs = queryKTIMLD4.executeQuery();
>while (rs.next() == true) {
>   tiatim = rs.getLong(1);
>   tisec2 = rs.getString(2);
>   tisec3 = rs.getString(3);
>   for (int j = 0; j <= 9; j++) {
>      pc[j] = rs.getString("tipc" + (Integer.toString(j+1)).trim());
>   }
>   for (int j = 0; j <= 9; j++) {
>      hrs[j] = rs.getBigDecimal("tihr" + (Integer.toString(j+1)).trim());
>   }
>   for (x = 0; x <= 9; x++) {
>      workCodeQuery = "select wcnonw from clocfile01.ckworkcd where 
wccode 
>= '" + pc[x].trim() + "'";
>      PreparedStatement queryCKWORKCD = 
>nal820.conn.prepareStatement(workCodeQuery);
>      ResultSet rs2 = queryCKWORKCD.executeQuery();
>      wcnonw = rs2.getString(1);
>      // further processing...
>   }
>   rs2.close();
>   queryCKWORKCD.close();
>}
>rs.close();
>queryKTIMLD4.close();
>
>Here's the error I'm getting...it's happening at the following line: 
>wcnonw = rs2.getString(1);
>
>Cursor position not valid.
>java.sql.SQLException: Cursor position not valid.
>        at java.lang.Throwable.<init>(Throwable.java:96)
>        at java.lang.Exception.<init>(Exception.java:44)
>        at java.sql.SQLException.<init>(SQLException.java:45)
>        at 
>com.ibm.as400.access.JDError.throwSQLException(JDError.java:395)
>        at 
>com.ibm.as400.access.AS400JDBCResultSet.getValue(AS400JDBCResultSet.java:3519)
>        at 
>com.ibm.as400.access.AS400JDBCResultSet.getString(AS400JDBCResultSet.java:3173)
>        at DailyLaborHours.addDay(DailyLaborHours.java:395)
>        at DailyLaborHours.getdata(DailyLaborHours.java:84)
>        at DailyLaborHours.main(DailyLaborHours.java:53)
>
>Do I have to do something special to be able to use a ResultSet of one 
>query inside the ResultSet of another query?...Thanks in advance...
>
>Shane Cessna 
>iSeries Programmer
>iSeries WAS Administrator
>North American Lighting, Inc.
>(618) 662-4483 x2776
>shane_cessna@xxxxxxx
> 
>



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.