问题描述
我为 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 发布到前端,请在此处输入图像描述
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)