0

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??

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194

1 Answers1

1

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

Christoph G
  • 555
  • 2
  • 8