How to check the availability of table using ResultSet !!!!
I'm using the resultset for displaying the datas from the databse. How i'll check the particular table (checking the condition) whether it is there or not in the database and it should give the boolean result. I'm using the resultset so how to do that with. Could anyone tell me that.
thanks in advance..
# 9
Wow. Is this thread a magnet for stupidity or what?
Just almost all wrong-headedness from start to finish.
First Post
"I'm using the resultset for displaying the datas from the databse. How i'll check the particular table (checking the condition) whether it is there or not in the database and it should give the boolean result. I'm using the resultset so how to do that with. Could anyone tell me that."
No. Mainly because your question is incoherent. I wonder what it is that you are really trying to do.
Reply #1
"i believe you want to find out if the resultset has the fields or not right?
which in turn implies that the databse must be havin it?
Well in that case u use Resultset rs right?
now u use if(rs.next!=null)
then wat it will do is first check if resultset is null or not, if not then there are some fields else it won;t exec wat is inside the if block.... "
Total, utter and complete rubbish. You couldn't be more wrong if you tried.
Reply # 2
"then what wiill be the rs. what query it should consist of. Suppose i'm writing this.
rs = executeQuer("select * from check");
if(rs.next!=null)
then it's giving error at the first line only.
what should i do now... "
For starters don't follow the advice of reply 1. It is is rubbish.
Reply #3
"it's not taking the
rs.next!=null
. != operator is not be used for this. as what i'm getting the compiler error. "
Again reply 1 is rubbish
Reply #4
"becase u have to uise ur Statement!!!!!!!!
Statement stat;
ResultSet rs=stat.executeQuery(..................); "
Are you a troll? Are you on drugs? What's the problem here KayDeE? Here's some good advice KayDeE , shut, the ****, up. You are too stupid to post here.
Reply #5
"Hai,
If u are using the Oracle give the following code to do this thing
......................
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from tab where tname like '"+yourtabname+"'");
if(!rs.next())
System.out.println("Table available");
else
System.out.println("Table not available");"
Hooray. Except for the lack of the code tags we finally have a correct answer. Thank you santhosh-mca I was losing faith in humanity.
Now of course it can be improved, could use DatabaseMetaData for one thing and it won't help Nanveet but at least this post actually might work at all unlike KayDeE's suggestions.
Reply #6
"No, i'm using the MSSQL 2005. Do u have any idea for this. How should i do the query. "
DatabaseMetaData, if you want to do what reply 5 is implying that you want. If it isn't then you need to start over and tell us in clear and less rambling terms what it is you want to do.
Last, please remember KayDeE is a dangerous fool and idiot and should be ignored.
# 11
> I must respectively disagree, Mr. Cotton.
> I believe that reply no. 8, out of all replies,
> represents the most correct answer-
> "Hey Navneet, what you have written is nonsense."
>
> Kind regards,
>
> Your friend.
There were only 6 replies when I started. Reply 7 is good as well, if that is what Navneet actually wants. I have no idea.