0

The following code is to fetch otp from SQL to the frontend

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class JavaConnect2SQL {

public static void main(String[] args) throws ClassNotFoundException, InterruptedException {

try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
// TODO Auto-generated method stub
//String url="jdbc:sqlserver://LAPTOP-F0E1C4GT\\SQLEXPRESS;databaseName=BikeStores;";
//String user="sa";
//String password="NewPassword@123";


String url = "jdbc:sqlserver://104.211.116.31:2658;user=username;password=pass;databaseName=ilend_live;columnEncryptionSetting=Enabled";
//connServer.connect(url);




Connection connection=DriverManager.getConnection(url);
System.out.println("Connected");
    Statement statement = connection.createStatement();
    

//*****
       
       
        System.setProperty("webdriver.chrome.driver","D:\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.navigate().to("https://indialends.com/");
        driver.findElement(By.linkText("Personal Loan")).click();
 
    //driver.findElement(By.name("li_display_name")).getAttribute(rs.getString(1));
    
    
    driver.navigate().to("https://indialends.com/");
    driver.manage().window().maximize();
    String s = driver.getCurrentUrl();

    System.out.println(s);
    driver.getTitle();
    String x = driver.getTitle();
    System.out.println(x);

 driver.findElement(By.linkText("Personal Loan")).click();
    driver.findElement(By.id("li_display_name")).sendKeys("RAVNEET KAUR");
    driver.findElement(By.id("email")).sendKeys("ravneetkaur@indialends.com");
    driver.findElement(By.name("pincode")).sendKeys("122018");
    driver.findElement(By.id("employment")).click();
    Thread.sleep(5000);
    driver.findElement(By.id("salaried12")).click();
    Thread.sleep(5000);

    driver.findElement(By.id("companyName")).sendKeys("INDIALENDS");

    Thread.sleep(10000);
    driver.findElement(By.id("monthlyIncome")).sendKeys("34000");
    driver.findElement(By.id("mobile")).sendKeys("9773555667");
    driver.findElement(By.id("li_submit")).click();
    Thread.sleep(5000);

    WebDriverWait wait = new WebDriverWait(driver, 30);
    wait.until(ExpectedConditions.presenceOfElementLocated(By.id("control-indicator"))).click();
    String s2 = driver.getCurrentUrl();
    WebDriverWait wait2 = new WebDriverWait(driver, 30);
    String query = "select top 1 v_code from mobileverification_encryption  order by v_code desc";
    ResultSet rs = statement.executeQuery(query);
    while(rs.next()){
       System.out.println(rs.getString(1));
       Thread.sleep(2000);
    driver.findElement(By.id("txt_otp")).sendKeys(rs.getString(1));
    Thread.sleep(2000);
    driver.findElement(By.id("btn_mobile_verify")).click();
    System.out.println(s2);
    driver.getTitle();
    String x1 = driver.getTitle();
    System.out.println(x1);
    Thread.sleep(5000);
    
  
    
} }catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("Oops,there is error");
e.printStackTrace();



}
//driver.findElement(By.id("txt_otp")).sendKeys("55555");
}

}

But since this table is OTP encrypted it is giving me the following exception in Eclipse

" java.lang.UnsatisfiedLinkError: com.microsoft.sqlserver.jdbc.AuthenticationJNI.DecryptColumnEncryptionKey(Ljava/lang/String;Ljava/lang/String;[B)[B
    at com.microsoft.sqlserver.jdbc.AuthenticationJNI.DecryptColumnEncryptionKey(Native Method)
    at com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionCertificateStoreProvider.decryptColumnEncryptionKeyWindows(SQLServerColumnEncryptionCertificateStoreProvider.java:61)
    at com.microsoft.sqlserver.jdbc.SQLServerColumnEncryptionCertificateStoreProvider.decryptColumnEncryptionKey(SQLServerColumnEncryptionCertificateStoreProvider.java:75)
    at com.microsoft.sqlserver.jdbc.SQLServerSymmetricKeyCache.getKey(SQLServerSymmetricKeyCache.java:130)
    at com.microsoft.sqlserver.jdbc.SQLServerSecurityUtility.decryptSymmetricKey(SQLServerSecurityUtility.java:161)
at com.microsoft.sqlserver.jdbc.SQLServerSecurityUtility.decryptWithKey(SQLServerSecurityUtility.java:206)
at com.microsoft.sqlserver.jdbc.ServerDTVImpl.getValue(dtv.java:3737)
at com.microsoft.sqlserver.jdbc.DTV.getValue(dtv.java:247)
at com.microsoft.sqlserver.jdbc.Column.getValue(Column.java:190)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2054)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getValue(SQLServerResultSet.java:2040)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getString(SQLServerResultSet.java:2511)
at JavaConnect2SQL.main(JavaConnect2SQL.java:80)

I don't understand how to fix this. What is wrong and how do I get it working?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.