Reputation: 3
I have two database table with same attributes. I want to use two sql statments one read from table n 2nd update table.
String tableName = "";
String value = request.getParameter("PageId");
if(value=="Alflah"){
tableName = "PARKTABLEONE";
}
if(value=="ParkN"){
tableName = "PARKTABLE";
}
One Statment:
ResultSet rs= st.executeQuery("Select * From " +tableName+ " WHERE ID = \'"+ login + "\' ");
2nd Statement:
String query = "update " + tableName + " set Place1 = ?, Place2 = ? WHERE ID = \'"+ login + "\'";
So, I want to use TableName variable here. For example if tablename is Alflah it shoud read from alflah Is it possible or not? please correct me where is my mistake??
Upvotes: 0
Views: 66
Reputation: 555
TableName is empty, that's why it says error at column 17. If WHERE starts at 17, then it must be empty, just count the characters
Upvotes: 1