0

Please help me out with this, there is problem with String qry.

import java.util.*; import java. public class AggregateFunction { public static void main(String[] args) { Connection con=null; Statement st=null; try { con=JdbcUtilMySql.getMySqlConnection(); st= con.createStatement(); Scanner sc = new Scanner(System.in); System.out.println("Enter Number: "); int n= sc.nextInt(); String qry ="select * from (select eid,ename,esal,eaddr,edpart,rank() over (order by esal DESC) as ranking from m.employee) where ranking: "+ n; ResultSet rs = st.executeQuery(qry); while (rs.next()) { System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3)+"\t"+rs.getString(4)+"\r"+rs.getString(5)); } sc.close(); }catch(Exception e) { e.printStackTrace(); } finally { JdbcUtilMySql.cleanup(st, con); } }

4th Oct 2020, 8:09 AM
Rajesh Deshbandhu
Rajesh Deshbandhu - avatar
1 Odpowiedź
0
Use hibernate)
8th Oct 2020, 9:10 AM
Marko Andrushchenko
Marko Andrushchenko - avatar