I wrote the below line for connection with sql server express r2:
Connection con=DriverManager.getConnection(\"jdbc:sqlserver://localhost/SQLEXPRESS;databaseName=abc
I also got the same problem in sqlserver2008. To resolve these issu follow the sets as below: Start sqlserver-> from login window select Options button-> Connection Properties-> Connect to Database-> Brows and select database name-> then below in Network protocol select TCP/IP. And do execute your program.