微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

加密列的 jdbc 连接时出现 SQL 异常

如何解决加密列的 jdbc 连接时出现 SQL 异常

我为 sql 中的 otp 表编写了 sql 连接的代码。我正在使用列加密设置 = 启用以从查询中获得结果,但 eclipse 中的相同查询给了我以下异常:

com.microsoft.sqlserver.jdbc.sqlServerException: The data types varchar(12) encrypted with (encryption_type = 'DETERMINISTIC',encryption_algorithm_name = 'AEAD_AES_256_CBC_HMAC_SHA_256',column_encryption_key_name = 'wc_local_machine_mv_column_key',column_encryption_key_database_name = 'Ilend_uat') collation_name = 'latin1_General_BIN2' and varchar are incompatible in the equal to 
operator.
    at 

com.microsoft.sqlserver.jdbc.sqlServerException.makeFromDatabaseError(sqlServerException.java:262)
        at com.microsoft.sqlserver.jdbc.sqlServerStatement.getNextResult(sqlServerStatement.java:1632)
        at com.mic

rosoft.sqlserver.jdbc.sqlServerStatement.doExecuteStatement(sqlServerStatement.java:872)
    

我的代码是这样的:

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://52.172.161.203;user=username;password=userpass;databaseName=Ilend_uat;column encryption setting = 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("5589019322");
    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 * from mobiLeverification_encryption WHERE mobileno='5589019322' order by mvid 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");
}

}

我错过了什么?

更新:我能够解决异常,但问题仍然存在,我试图从 DATABASE 获取的 otp 已加密,我想将其转换为 6 位 otp 并传递到 otp 上的前端弹出。 Eclipse 像这样返回给我在这里输入图像描述

在 db 中它很好,因为我们使用列加密设置 = 启用如果在查询字符串中我通过“列加密设置 = 启用”,那么如何在 JDBC 中处理这个同时进行连接,然后它再次给出异常字符串 url =“jdbc: sqlserver://104.211.116.31:2658;user=username;password=pass;databaseName=ilend_live;columnEncryptionSetting=Enabled”;我正在尝试将此 v_code 发布到前端,请在此处输入图像描述

enter image description here

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?