I have Database on my server which I am accessing via my Java app. First it was MySQL database but now we changed server and we are using SQL.
Now I am re-writing the code and I have exception when I am reading from it.
In one of functions I use the following select:
String sql2="SELECT * FROM \""+item1+"\" WHERE name=? or codeID=?";
pst2=con.prepareStatement(sql2);
pst2.setString(1, listBox.getSelectedValue());
pst2.setString(2, listBox.getSelectedValue());
rs2=pst2.executeQuery();
When I try to get in while loop:
while(rs2.next()){
//some code
}
I am getting this error:
com.microsoft.sqlserver.jdbc.SQLServerException: Conversion failed when converting the nvarchar value '[some varchar value]' to data type int.
I understand what is the problem but I am not sure how to resolve it. I never faced this issue when I was working with MySQL.