I have been banging my head for the integration of like operation by ms sql server Always Encryption using Secure enclaves and JDBC
I have an encrypted column(name) on a table(student) using the randomized encryption and able to get the decrypted data using the following query using SSMS
DECLARE @name char(200) = ‘stack%’;
SELECT name, subject FROM student WHERE name LIKE @name;
The above script to get executed, I have enabled Always Encryption and Enable Secure Enclaves and Enclave Attestation Protocol as None
[![enter image description here][1]][1]
Also added Column Encryption Setting = Enabled
[![enter image description here][2]][2]
I am using JDBC application to connect to the encrypted database
Connection string: jdbc:sqlserver://server:port;databaseName=database;SelectMethod=cursor;columnEncryptionSetting=Enabled;enclaveAttestationUrl=null;enclaveAttestationProtocol=NONE
below is the code to get the data
String sql = "DECLARE @name char(200) = 'stack%'; "
+ "SELECT name FROM Student WHERE name LIKE @name;";
DatabaseManager db = null;
ResultSet rs = null;
List list = new ArrayList();
try {
db = getDatabaseManager();
rs = db.executeQuery(sql);
while (rs.next()) {
System.out.println(rs.getString("CustomerName_1"));
}
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
if (db != null) {
db.close();
db = null;
}
}
````
But when running the application, I am unable to get the data and encountering the below exception
***Encryption scheme mismatch for columns/variables '@CustomerName_1'. The encryption scheme for the columns/variables is (encryption_type = 'PLAINTEXT') and the expression near line '1' expects it to be Randomized, , a BIN2 collation for string data types, and an enclave-enabled column encryption key, or PLAINTEXT.***
[1]: https://i.sstatic.net/pz5w6T9f.png
[2]: https://i.sstatic.net/CbqwRXAr.png
It is killing my time almost and any help would be appreciable and helpful