Hi, Team,
I am working on Web application automation I have scenario like to login into the application I have i have to enter mobile number after that get the OTP on mobile number so I have to enter that OTP into web application so for that I am fetching that OTP from my SQL database and able to print the correct OTP but when I try to pass the OTP in web element using sendkeys it throws me error.
Sharing code for the same and please help me with this.
CODE
Connection con = (Connection) DriverManager.getConnection(
"jdbc:mysql://mysqldev.db.flexi.com:3307/ldb", "bhupendra_n",
"asd$fdsfds");
Statement stmt = (Statement) con.createStatement();
System.out.println("Connected");
ResultSet rs = stmt.executeQuery("select otp from otp_user where mobile_no='9544377429' order by created_at desc limit 1;");
while (rs.next())
System.out.println(rs.getString("otp"));
Thread.sleep(10000);
//int i=Integer.parseInt(rs.getString("otp"));
//rs.getString("otp");
driver.findElement(By.xpath("//input[@ng-reflect-name='otp1']")).sendKeys(rs.getString("otp"));
con.close();
ERROR
Exception in thread "main" java.sql.SQLException: After end of result set
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:896)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:885)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:790)
at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5244)
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5167)
at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5206)
at roughPrograms.f0Card01.main(f0Card01.java:54)