I have an Array List which contains Strings:
ArrayList<String> anrs = new ArrayList<>();
Now I convet those into an SQL array like this:
final String[] data = anrs.toArray(new String[anrs.size()]);
final java.sql.Array sqlArray = connection.createArrayOf("varchar", data);
And now I want to make a prepared statement like this:
statement = connection.createStatement();
String selectSQL = "SELECT * FROM rekopf INNER JOIN repos ON rekopf.rekopfnum=repos.Reposnum WHERE repos.reposart IN ?";
pstatement = connection.prepareStatement(selectSQL);
pstatement.setArray(1, sqlArray);
resultSet = pstatement.executeQuery();
But I got this error:
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.1 unexpected token: ? required:
error occures in this line: pstatement = connection.prepareStatement(selectSQL);
What is my issue in this case? Thanks in advance.
Update When I try it like this:
pstatement.setArray(1, connection.createArrayOf("varchar", data));
Then I got this error
net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.1 incompatible data type in conversion