java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
java.util.NoSuchElementException
- All Implemented Interfaces:
- Serializable
- Direct Known Subclasses:
- InputMismatchException
- See Also:
- Top Examples, Source Code,
Enumeration ,
Enumeration.nextElement()
public NoSuchElementException() - Geek's Notes:
- Description Add your codes or notes Search More Java Examples
[1188]_ By ashpak_pathan { at } rediffmail { dot } com on 2004/12/11 05:07:40 Rate
When i store the elements in the CSV file at that time this exception found [1468]Parse string with StringTokenizer By mousumi_rkl { at } rediffmail { dot } com on 2005/07/01 02:55:21 Rate
package mousumi; import java.io.*; import java.util.*; import xBaseJ.*; public class trans { public static void main ( String args [ ] ) { NumField srno=null; NumField binkey=null; NumField Aflskucode=null; CharField Uomcode=null; CharField Fifodate=null; CharField Year=null; NumField Qty=null; NumField Qtypicked=null; CharField Barcodeined=null; DBF ADB=null; try { ADB=new DBF ( "D:/mou/scanmast.dbf" ) ; System.out.println ( "opening" ) ; srno= ( NumField ) ADB.getField ( "Invsrno" ) ; binkey= ( NumField ) ADB.getField ( "Binkey" ) ; Aflskucode= ( NumField ) ADB.getField ( "Aflskucd" ) ; Uomcode= ( CharField ) ADB.getField ( "Uomcode" ) ; Fifodate= ( CharField ) ADB.getField ( "Fifodate" ) ; Year= ( CharField ) ADB.getField ( "Year" ) ; Qty= ( NumField ) ADB.getField ( "Qty" ) ; Qtypicked= ( NumField ) ADB.getField ( "Qtypicked" ) ; Barcodeined= ( CharField ) ADB.getField ( "BARCODEIND" ) ; InputStream is=new FileInputStream ( "D:/mou/ritu.txt" ) ; BufferedReader br= new BufferedReader ( new InputStreamReader ( is ) ) ; String s = null; while ( ( s= br.readLine ( ) ) != null ) { System.out.println ( s ) ; StringTokenizer s1 = new StringTokenizer ( s,"," ) ; while ( s1.hasMoreTokens ( ) ) { String inv=s1.nextToken ( ) ; System.out.println ( "inv:"+inv ) ; String bkey=s1.nextToken ( ) ; System.out.println ( "bkey:"+bkey ) ; String bincd=s1.nextToken ( ) ; System.out.println ( "bincd:"+bincd ) ; String aflskucd=s1.nextToken ( ) ; String aflscd=aflskucd.substring ( 1,9 ) ; System.out.println ( "aflscd:"+aflscd ) ; String Uom=aflskucd.substring ( 9,13 ) ; System.out.println ( "Uom"+Uom ) ; String fifo=aflskucd.substring ( 13, ( aflskucd.length ( ) -1 ) ) ; System.out.println ( "fifo"+fifo ) ; String year=fifo.substring ( ( fifo.length ( ) -2 ) ,fifo.length ( ) ) ; System.out.println ( "year"+year ) ; //System.out.println ( "name:"+aflscd ) ; String custscd=s1.nextToken ( ) ; System.out.println ( "custcd"+custscd ) ; String qty=s1.nextToken ( ) ; System.out.println ( "qty"+qty ) ; String Qtysofar=s1.nextToken ( ) ; System.out.println ( "qtysofar"+qty ) ; String flag=s1.nextToken ( ) ; System.out.println ( "err ck"+flag ) ; } System.out.print ( "after write" ) ; } } catch ( FileNotFoundException e7 ) { // TODO Auto-generated catch block e7.printStackTrace ( ) ; } catch ( IOException e11 ) { // TODO Auto-generated catch block e11.printStackTrace ( ) ; } catch ( xBaseJException e1111 ) { // TODO Auto-generated catch block e1111.printStackTrace ( ) ; } } private static void Qtypicked ( String qty ) { // TODO Auto-generated method stub } //end of 1st if } [2015]How to catch NoSuchElementException in following code By chandu { dot } karkare1111 { at } gmail { dot } com on 2010/12/22 05:35:10 Rate
package beans.StaffLeave; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import java.sql.Types; import java.util.Hashtable; import java.util.PropertyResourceBundle; import java.util.StringTokenizer; import java.util.Vector; import org.apache.commons.collections.OrderedMap; import org.apache.commons.collections.map.LinkedMap; import eth.factory.ConnectionFactory; import eth.i18n.ETHi18n; import eth.logger.ETHLogger; public class LeaveTransEntryBean { public OrderedMap getUsersDetail ( ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; StringBuffer sb = new StringBuffer ( ) ; ETHi18n i18n = new ETHi18n ( ) ; PropertyResourceBundle prbUM = i18n.getETHi18nVar ( "UserManagement" ) ; String sysadmin = prbUM.getString ( "sysadmin" ) ; String sadmin = prbUM.getString ( "sadmin" ) ; sb.append ( " select " ) ; sb.append ( " replace ( coalesce ( u.first_name,'' ) ,'-','' ) , " ) ; sb.append ( " replace ( coalesce ( u.middle_name,'' ) ,'-','' ) ," ) ; sb.append ( " replace ( coalesce ( u.last_name,'' ) ,'-','' ) ," ) ; sb.append ( " sd.loginid ,sd.type_id,u.gender,st.type_desc " ) ; sb.append ( " ,convert ( char,case when sd.joining_date_institution is null then u.registration_date else sd.joining_date_institution end,101 ) " ) ; sb.append ( " from users u,staff_details sd , staff_type st" ) ; sb.append ( " where u.loginid=sd.loginid and u.status='V'" ) ; sb.append ( " and sd.type_id = st.type_id and st.status='V' and upper ( u.loginid ) NOT IN ( 'SYSADMIN','PADMIN','SADMIN' ) " ) ; sb.append ( " order by rtrim ( ltrim ( u.first_name ) ) ,u.middle_name,u.last_name" ) ; String sql_qry = sb.toString ( ) ; OrderedMap userDet = new LinkedMap ( ) ; try { con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( sql_qry ) ; if ( rs != null ) { if ( rs.next ( ) ) { do { String name = rs.getString ( 1 ) + " " + rs.getString ( 2 ) + " " + rs.getString ( 3 ) ; Vector data = new Vector ( ) ; data.add ( name ) ; //at 0 position name data.add ( rs.getString ( 5 ) ) ; //at 1 position type id data.add ( rs.getString ( 6 ) ) ; //at 2 position gender data.add ( rs.getString ( 7 ) ) ; //at 3 position type_desc data.add ( rs.getString ( 8 ) ) ; //at 3 joining date institution userDet.put ( rs.getString ( 4 ) , data ) ; data = null; } while ( rs.next ( ) ) ; } } } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return userDet; } // public Hashtable getStaffType ( ) { Hashtable result = new Hashtable ( ) ; ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; StringBuffer sb = new StringBuffer ( ) ; sb.append ( " Select distinct type_id,type_desc " ) ; sb.append ( " from staff_type where status='V';" ) ; String sql_qry = sb.toString ( ) ; try { con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( sql_qry ) ; if ( rs.next ( ) ) { do { result.put ( new Integer ( rs.getInt ( 1 ) ) , rs.getString ( 2 ) ) ; } while ( rs.next ( ) ) ; } } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return result; } // public Vector getLoinId ( ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; Vector result = new Vector ( ) ; String sql_qry = "Select loginid from staff_details sd ,users u where sd.loginid=u.loginid and u.status='V'"; try { con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( sql_qry ) ; if ( rs.next ( ) ) { do { result.add ( rs.getString ( 1 ) ) ; } while ( rs.next ( ) ) ; } } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return result; } public Hashtable getLeaveDetail ( ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Hashtable result = new Hashtable ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; StringBuffer query = new StringBuffer ( ) ; Vector data = null; query.append ( " select lim.type_id,lim.leave_id,case when lim.max_no_of_days is null then 0.00 else lim.max_no_of_days end,max_days_service,lm.leave_desc, " ) ; query.append ( " lm.carry_forward_flag,lm.applicable_to_gender,lim.leave_limit_id " ) ; query.append ( " ,lm.eligible_month_after_doj,lm.duration_between_leaves ,lm.applicable_months,lim.frequency " ) ; query.append ( " from leave_limit lim, leave_master lm " ) ; query.append ( " where lm.leave_id=lim.leave_id and lm.status='V' and lim.status = 'V' order by type_id,leave_id;" ) ; ETHLogger.log ( "====query============= "+query ) ; try { con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( query.toString ( ) ) ; if ( rs != null ) { while ( rs.next ( ) ) { Integer key = new Integer ( rs.getInt ( 1 ) ) ; if ( result.containsKey ( key ) ) { data = ( Vector ) result.get ( key ) ; } else { data = new Vector ( ) ; } String detail = rs.getString ( 2 ) + "$" + rs.getString ( 3 ) + "$" + rs.getString ( 4 ) + "$" + rs.getString ( 5 ) + "$" + rs.getString ( 6 ) + "$" + rs.getString ( 7 ) + "$" + rs.getString ( 8 ) + "$" + rs.getString ( 9 ) + "$" + rs.getString ( 10 ) + "$" + rs.getString ( 11 ) + "$" + rs.getString ( 12 ) ; data.add ( detail ) ; result.put ( key, data ) ; } //end of while } } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return result; } / public int getBalanceLeave ( String loginId, int leaveLimitId, int leaveId ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; int result = 0; try { con = cf.getConnection ( ) ; StringBuffer query = new StringBuffer ( ) ; query.append ( "select no_days from leave_transaction lt, admin_year ay where loginid='"+ loginId+ "' and " ) ; query.append ( " leave_limit_id=" + leaveLimitId + " and leave_id=" + leaveId+" and lt.admin_year_id = ay.academic_year_id and ay.status = 'V' " ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( query.toString ( ) ) ; if ( rs.next ( ) ) { result = rs.getInt ( 1 ) ; } } catch ( Exception se ) { ETHLogger.log ( se ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } //end of catch } // End of finally return result; } / public int insertLeaveTransaction ( String leaveDetails, String adminLogin, String upmark, String ltype ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; CallableStatement cstmt = null; //boolean result = false; int result = 0; String mainString [ ] =null; String loginidStr=null; String valueArr [ ] =null; String loginid=null; String values=null; String valueStr=null; String carry_fwd=null; String leave_limit_id =null; String leave_id=null; String max_days=null; String eligible_month_after_doj=null; String duration_between_leaves =null; String applicable_months=null; String last_leave_from_date=null; String last_leave_to_date =null; String last_leave_no_of_days=null; String frequency=null; String month_id=null; String month_order=null; StringBuffer xmlStr=new StringBuffer ( ) ; xmlStr.append ( " < root > " ) ; StringTokenizer token,token2=null; mainString = leaveDetails.split ( "~" ) ; for ( int i=0;i < mainString.length;i++ ) { loginidStr=mainString [ i ] ; token = new StringTokenizer ( loginidStr,"$" ) ; loginid=token.nextToken ( ) ; valueStr=token.nextToken ( ) ; valueArr=valueStr.split ( "#" ) ; for ( int k=0;k < valueArr.length;k++ ) { values = valueArr [ k ] ; token2 = new StringTokenizer ( values,"_" ) ; xmlStr.append ( " < trans loginid=\""+loginid+"\" " ) ; ETHLogger.log ( "trans loginid="+loginid ) ; carry_fwd = token2.nextToken ( ) ; xmlStr.append ( "carry_fwd=\""+carry_fwd+"\" " ) ; ETHLogger.log ( "carry_fwd="+carry_fwd ) ; leave_limit_id =token2.nextToken ( ) ; xmlStr.append ( "leave_limit_id=\""+leave_limit_id+"\" " ) ; ETHLogger.log ( "leave_limit_id="+leave_limit_id ) ; leave_id=token2.nextToken ( ) ; xmlStr.append ( "leave_id=\""+leave_id+"\" " ) ; ETHLogger.log ( "leave_id="+leave_id ) ; max_days=token2.nextToken ( ) ; xmlStr.append ( "max_days=\""+max_days+"\" " ) ; ETHLogger.log ( "max_days="+max_days ) ; eligible_month_after_doj=token2.nextToken ( ) ; xmlStr.append ( "eligible_month_after_doj=\""+eligible_month_after_doj+"\" " ) ; ETHLogger.log ( "eligible_month_after_doj="+eligible_month_after_doj ) ; duration_between_leaves =token2.nextToken ( ) ; xmlStr.append ( "duration_between_leaves=\""+duration_between_leaves+"\" " ) ; applicable_months=token2.nextToken ( ) ; xmlStr.append ( "applicable_months=\""+applicable_months+"\" " ) ; last_leave_from_date=token2.nextToken ( ) ; xmlStr.append ( "last_leave_from_date=\""+last_leave_from_date+"\" " ) ; last_leave_to_date =token2.nextToken ( ) ; xmlStr.append ( "last_leave_to_date=\""+last_leave_to_date+"\" " ) ; last_leave_no_of_days=token2.nextToken ( ) ; xmlStr.append ( "last_leave_no_of_days=\""+last_leave_no_of_days+"\" " ) ; frequency=token2.nextToken ( ) ; xmlStr.append ( "frequency=\""+frequency+"\" " ) ; month_id=token2.nextToken ( ) ; xmlStr.append ( "month_id=\""+month_id+"\" " ) ; month_order=token2.nextToken ( ) ; xmlStr.append ( "month_order=\""+month_order+"\" " ) ; xmlStr.append ( "/ > " ) ; } } xmlStr.append ( " < /root > " ) ; ETHLogger.log ( "xmlStr "+xmlStr ) ; try { ETHLogger.log ( "SELECT fun_insert_leave_transaction ( '"+xmlStr.toString ( ) +"','"+adminLogin+"','"+upmark+"','"+ltype+"' ) ;" ) ; con = cf.getConnection ( ) ; cstmt = con.prepareCall ( " { call fun_insert_leave_transaction ( ?,?,?,?,? ) } " ) ; cstmt.registerOutParameter ( 1, java.sql.Types.INTEGER ) ; cstmt.setString ( 2, xmlStr.toString ( ) ) ; cstmt.setString ( 3, adminLogin ) ; cstmt.setString ( 4, upmark ) ; cstmt.setString ( 5, ltype ) ; cstmt.executeUpdate ( ) ; result = cstmt.getInt ( 1 ) ; } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( cstmt != null ) { cstmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return result; } public OrderedMap getCarryFwd ( ) { ConnectionFactory cf = null; Connection con = null; CallableStatement cs = null; ResultSet rs = null; OrderedMap login = null; OrderedMap leave = null; Vector vecLogin =null; try { cf = new ConnectionFactory ( ) ; con = cf.getConnection ( ) ; login = new LinkedMap ( ) ; leave = new LinkedMap ( ) ; vecLogin=new Vector ( ) ; cs=con.prepareCall ( " { call fun_get_carry_forward ( ) } " ) ; //cs.registerOutParameter ( 1, Types.OTHER ) ; //cs.setObject ( 2,rs ) ; //con.setAutoCommit ( false ) ; rs=cs.executeQuery ( ) ; //rs = ( ResultSet ) cs.getObject ( 1 ) ; if ( rs.next ( ) ) { String loginid = null; int leave_id = 0,monthid=0,monthorderid=0; float carry_fwd = 0; String freq=null,formula=null; do { loginid =rs.getString ( 1 ) ; leave_id =rs.getInt ( 2 ) ; carry_fwd = rs.getFloat ( 3 ) ; freq= rs.getString ( 4 ) .trim ( ) ; monthid=rs.getInt ( 5 ) ; monthorderid=rs.getInt ( 6 ) ; formula=rs.getString ( 7 ) ; if ( login.containsKey ( loginid ) ) { leave= ( OrderedMap ) login.get ( loginid ) ; } else { leave= new LinkedMap ( ) ; } if ( monthid > 0 && !vecLogin.contains ( loginid ) ) { vecLogin.add ( loginid+"$"+leave_id ) ; } leave.put ( leave_id+"",carry_fwd+"\uB006"+freq+"\uB006"+monthid+"\uB006"+monthorderid+"\uB006"+formula ) ; login.put ( loginid,leave ) ; login.put ( "vecLogin", vecLogin ) ; } while ( rs.next ( ) ) ; } //end of if } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( cs != null ) { cs.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return login; } public int deleteExisting ( String login, int acad_id, int lev_id ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; Statement stmt1 = null; ResultSet rs = null; int result = 0, count = 0; String sql_qry = " Select count ( * ) from leave_transaction where admin_year_id=" + acad_id + " and loginid='" + login + "'"; String del_qry = " Delete from leave_transaction where admin_year_id=" + acad_id + " and loginid='" + login + "'"; try { con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( sql_qry ) ; if ( rs != null ) { rs.next ( ) ; count = rs.getInt ( 1 ) ; } if ( count > 0 ) { stmt1 = con.createStatement ( ) ; result = stmt1.executeUpdate ( del_qry ) ; } } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( stmt1 != null ) { stmt1.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return result; } private void archiveTransData ( String loginid, int acad_id ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; PreparedStatement pstmt = null; ResultSet rs = null; String ins_qry = "Insert into leave_transaction_archive ( leave_transaction_archive_id,admin_year_id,leave_id," + "no_days,carry_fwd,loginid, leave_group_id,valid_to ) " + "values ( nextval ( 'leave_transaction_archive_seq' ) ,?,?,?,?,?,?,now ( ) ) "; String sel_qry = "select loginid,admin_year_id,leave_id,no_days,carry_fwd,leave_group_id " + " from leave_transaction where loginid='" + loginid + "' and admin_year_id=" + acad_id; int cnt = 0; try { con = cf.getConnection ( ) ; pstmt = con.prepareStatement ( ins_qry ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( sel_qry ) ; if ( rs != null ) { while ( rs.next ( ) ) { pstmt.setInt ( 1, rs.getInt ( 2 ) ) ; pstmt.setInt ( 2, rs.getInt ( 3 ) ) ; pstmt.setInt ( 3, rs.getInt ( 4 ) ) ; pstmt.setInt ( 4, rs.getInt ( 5 ) ) ; pstmt.setInt ( 6, rs.getInt ( 6 ) ) ; pstmt.setString ( 5, rs.getString ( 1 ) ) ; pstmt.addBatch ( ) ; cnt++; } } if ( cnt > 0 ) { pstmt.executeBatch ( ) ; if ( stmt != null ) { stmt.close ( ) ; stmt = null; } stmt = con.createStatement ( ) ; stmt.executeUpdate ( "delete from leave_transaction where admin_year_id =" + acad_id + " " + " and loginid = '" + loginid + "' " ) ; } // } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( pstmt != null ) { pstmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } } public int getAcademicYearId ( ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; String sql = null; int academic_year_id = 0; try { sql = " select academic_year_id from academic_year where status='V' "; con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( sql ) ; if ( rs.next ( ) ) { academic_year_id = rs.getInt ( 1 ) ; } // } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } //End finally return academic_year_id; } // public Hashtable getNoOfDays ( ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; Hashtable result = new Hashtable ( ) ; StringBuffer query = new StringBuffer ( ) ; query.append ( " select lt.loginid,lt.no_days,lt.leave_id,ll.type_id,ay.admin_year_id from leave_transaction lt, " ) ; query.append ( " admin_year ay,leave_limit ll where lt.admin_year_id = ay.admin_year_id and lt.leave_id = ll.leave_id" ) ; query.append ( " and ay.status = 'V' order by type_id;" ) ; String loginId = null; Hashtable data = null; try { con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( query.toString ( ) ) ; while ( rs.next ( ) ) { loginId = rs.getString ( 1 ) ; if ( result.containsKey ( loginId ) ) { data = ( Hashtable ) result.get ( loginId ) ; //int carryforword = getCarryFwd ( loginId,rs.getInt ( 3 ) ,rs.getInt ( 5 ) ) ; data.put ( new Integer ( rs.getInt ( 3 ) ) , rs.getInt ( 2 ) + "$" + rs.getInt ( 4 ) ) ; } else { data = new Hashtable ( ) ; //int carryforword = getCarryFwd ( loginId,rs.getInt ( 3 ) ,rs.getInt ( 5 ) ) ; data.put ( new Integer ( rs.getInt ( 3 ) ) , rs.getInt ( 2 ) + "$" + rs.getInt ( 4 ) ) ; } result.put ( loginId, data ) ; } } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return result; } //End of method public OrderedMap getExistingLoginLeave ( ) { ConnectionFactory cf = new ConnectionFactory ( ) ; OrderedMap result = new LinkedMap ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; String sql_qry = " Select loginid from leave_transaction lt, admin_year ay " + " where lt.admin_year_id = ay.admin_year_id " + " and ay.status = 'V' "; try { con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( sql_qry ) ; if ( rs.next ( ) ) { do { result.put ( rs.getString ( 1 ) , "" ) ; } while ( rs.next ( ) ) ; } } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return result; } //End of method public OrderedMap getStaffTypeLeave ( ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; OrderedMap result = new LinkedMap ( ) ; String sql_qry = " SELECT DISTINCT type_id,staff_leave_group_id FROM staff_leave_group_type "; try { con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( sql_qry ) ; if ( rs.next ( ) ) { do { result.put ( new Integer ( rs.getInt ( 1 ) ) , rs.getString ( 2 ) ) ; } while ( rs.next ( ) ) ; } } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) rs.close ( ) ; if ( stmt != null ) stmt.close ( ) ; if ( con != null ) cf.freeConnection ( con ) ; } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; // e.printStackTrace ( ) ; } } return result; } //End of method getStaffTypeLeave ( ) public String insertLeaveTransaction ( String leaveDetail ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; CallableStatement cstmt = null; String message = ""; try { con = cf.getConnection ( ) ; cstmt = con.prepareCall ( " { call fun_leave_transaction ( ?,? ) } " ) ; cstmt.registerOutParameter ( 1, Types.VARCHAR ) ; cstmt.setString ( 2, leaveDetail ) ; cstmt.executeUpdate ( ) ; message = cstmt.getString ( 1 ) ; } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( cstmt != null ) { cstmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return message; } // This method returns the leave limit for all the leaves defined public OrderedMap getLeaveLimit ( ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; OrderedMap leaveLimitOm = new LinkedMap ( ) ; String query = "SELECT leave_limit_id, leave_id, max_no_of_days, max_days_service FROM leave_limit WHERE status ='V'"; try { con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( query ) ; while ( rs.next ( ) ) { String idString = rs.getInt ( 1 ) +"_"+rs.getInt ( 2 ) ; String daysString = rs.getInt ( 3 ) +"_"+rs.getInt ( 4 ) ; leaveLimitOm.put ( idString, daysString ) ; } } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( Exception e ) { ETHLogger.log ( e ) ; } } return leaveLimitOm; } //end of getLeaveLimit ( ) public OrderedMap getLeaveBalance ( ) { ConnectionFactory mc = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; OrderedMap result = new LinkedMap ( ) ; OrderedMap loginid = new LinkedMap ( ) ; OrderedMap leave = new LinkedMap ( ) ; OrderedMap leaveTakenStaff = new LinkedMap ( ) ; try { con = mc.getConnection ( ) ; StringBuffer query = new StringBuffer ( ) ; query.append ( " select loginid,coalesce ( no_days,0 ) , leave_limit_id, leave_id,frequency from leave_transaction lt, admin_year ay where " ) ; query.append ( " lt.admin_year_id = ay.admin_year_id and ay.status = 'V' and upper ( loginid ) NOT IN ( 'SYSADMIN','PADMIN','SADMIN' ) " ) ; ETHLogger.log ( "------query-------------------- "+query ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( query.toString ( ) ) ; while ( rs.next ( ) ) { String login = rs.getString ( 1 ) ; String leave_limit = rs.getString ( 3 ) ; String leave_id = rs.getString ( 4 ) ; //String frequency= rs.getString ( 5 ) .trim ( ) ; leaveTakenStaff.put ( login, "" ) ; if ( !loginid.containsKey ( login ) ) loginid.put ( login+"$"+leave_id,"" ) ; leave.put ( login+"$"+leave_limit+"$"+leave_id, rs.getString ( 2 ) ) ; } result.put ( "loginid",loginid ) ; result.put ( "leave",leave ) ; result.put ( "leaveTakenStaff",leaveTakenStaff ) ; ETHLogger.log ( "------query-------result---- "+result ) ; } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { mc.freeConnection ( con ) ; } } catch ( Exception e ) { ETHLogger.log ( e ) ; } //end of catch } // End of finally return result; } //end of getLeaveBalance public OrderedMap getUsersDetail ( String department_id ) { ConnectionFactory cf = new ConnectionFactory ( ) ; Connection con = null; Statement stmt = null; ResultSet rs = null; StringBuffer sb = new StringBuffer ( ) ; ETHi18n i18n = new ETHi18n ( ) ; PropertyResourceBundle prbUM = i18n.getETHi18nVar ( "UserManagement" ) ; String sysadmin = prbUM.getString ( "sysadmin" ) ; String sadmin = prbUM.getString ( "sadmin" ) ; sb.append ( " select " ) ; sb.append ( " replace ( coalesce ( u.first_name,'' ) ,'-','' ) , " ) ; sb.append ( " replace ( coalesce ( u.middle_name,'' ) ,'-','' ) ," ) ; sb.append ( " replace ( coalesce ( u.last_name,'' ) ,'-','' ) ," ) ; sb.append ( " ed.loginid , st.type_id, u.gender,st.type_desc , " ) ; sb.append ( " convert ( char,case when sd.joining_date_institution is null then u.registration_date else sd.joining_date_institution end ,101 ) , " ) ; sb.append ( " ll.leave_id from users u,staff_details sd , employee_job_details ed,designation_master dm, staff_type st LEFT JOIN leave_limit ll ON ( st.type_id=ll.type_id ) " ) ; sb.append ( " JOIN leave_master lm ON ( lm.leave_id=ll.leave_id ) " ) ; sb.append ( " where u.loginid=sd.loginid " ) ; if ( department_id!=null && !department_id.equalsIgnoreCase ( "" ) ) { sb.append ( " and ed.department_id = "+department_id ) ; } sb.append ( " and sd.type_id = st.type_id and ed.designation_id = dm.designation_id " ) ; sb.append ( " and sd.loginid = ed.loginid and u.status='V' and dm.status='V' and ed.status='V' and st.status='V'" ) ; sb.append ( " and upper ( u.loginid ) NOT IN ( 'SYSADMIN','PADMIN','SADMIN' ) " ) ; sb.append ( " order by rtrim ( ltrim ( u.first_name ) ) ,u.middle_name,u.last_name" ) ; ETHLogger.log ( "-----::sb::-------"+sb ) ; String sql_qry = sb.toString ( ) ; OrderedMap userDet = new LinkedMap ( ) ; try { con = cf.getConnection ( ) ; stmt = con.createStatement ( ) ; rs = stmt.executeQuery ( sql_qry ) ; if ( rs != null ) { if ( rs.next ( ) ) { do { String name = rs.getString ( 1 ) + " " + rs.getString ( 2 ) + " " + rs.getString ( 3 ) ; Vector data = new Vector ( ) ; data.add ( name ) ; //at 0 position name data.add ( rs.getString ( 5 ) ) ; //at 1 position type id data.add ( rs.getString ( 6 ) ) ; //at 2 position gender data.add ( rs.getString ( 7 ) ) ; //at 3 position type_desc data.add ( rs.getString ( 8 ) ) ; //at 3 joining date institution userDet.put ( rs.getString ( 4 ) +"$"+rs.getString ( 9 ) , data ) ; data = null; } while ( rs.next ( ) ) ; } } } catch ( Exception e ) { ETHLogger.log ( e ) ; } finally { try { if ( rs != null ) { rs.close ( ) ; } if ( stmt != null ) { stmt.close ( ) ; } if ( con != null ) { cf.freeConnection ( con ) ; } } catch ( SQLException sqle ) { ETHLogger.log ( sqle ) ; } } return userDet; } }
public NoSuchElementException(String s) - Geek's Notes:
- Description Add your codes or notes Search More Java Examples
| Popular Tags |