You are literally passing the string "server=.;uid=id;pwd=pw;database=db". I see you have parameters server1, id, pw, and db. I imagine you hardcoded the server in this string just to get this far, but you need to construct your string from your parameters. Something like:
String connstr = "Server="+server1+"; uid="+id+";pwd="+pw+";database="+db;
SqlConnection con = new SqlConnection(connstr);
or the like.
In this context, your parameters are not being used.
Hope this helps,
John (MSFT)