This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In MYDB database, I'm having three users 'dbo', 'alldata', 'user1'. My actual 'Addresses' table is in alldata and having views with name 'Addresses' in dbo and user1. Users 'alldata', 'user1' has no login names but user 'dbo' has login name 'sa'.
The above code just print: Name = Addesses Schema = dbo
but if I rename the view 'Adresses'in dbo i get: Name = Addresses Schema = alldata Name = Addresses Schema = user1
but if I change the line 2 in above code as: ResultSet rs1 = dbm.getTables("MYDB","alldata","Addresses", null);
I get following output: Name = Addresses Schema = alldata
I just want to know why the code snipett above doesn't geive me required output i.e. Name = Addesses Schema = dbo Name = Addresses Schema = alldata Name = Addresses Schema = user1
I think this features depends on driver which you are using. Better way is to use system catalogs to obtain database objects itself. For MSSQL look into the master database in system tables. There are also system stored procedures which helps you with system tables.