HI

I m using excel as a database..

In my DB i m having fields name and some value assigned to each name..

Now on my jsp page i m generating an array of names by some processing..

Now what i want is to access the names from the DB which r nor present in the array that i've generated. Want to get names and values other than array names..

how can i do this..

plz reply.

thanks

It might help if you showed your code (and hopefully the DB stuff is in a bean and is not a scriptlet in your jsp), and then trying to better explain what it is you want, because I'm not at all sure of what it is you're asking here.

Also, use code tags when you post your code.

Excel is no database.
Using JDBC to access Excel is BAD.
Using JDBC from JSP is BAD.

So it seems like you'd best completely scrap whatever you have already and start from scratch with some research into proper application architecture.

If your question is about accessing the excel as your DB, then:

Microsoft provides a driver for that, and you can use JDBC to access your excel (DB) like any other database. you need to create a data source for your excel (DB).

Comments
nonsense

NO, you do NOT use Excel as a database.
That's already been established firmly.
Excel is NOT a database.

Just because you can create ODBC DSNs to Excel files doesn't mean you should use those DSNs as database aliasses.

Hi all

thanks for all reply..

i just want to know how to compare a field in a database with the array..

means suppose i've array of names and i want to access those names from the database other than the array that i've.

i m using--

for(int i=0;i<my_arr.length;i++)
{
query = "select * from my_table where HR=(select max(HR) from my_table where FirstName <>'"+my_arr[l]+	"' )";
}

here actually i want to compare FirstName with total my_arr..
Means get HR whose FirstName is not equals to all names in my_arr.
As per i m using it'll compare only one name at a time,but i want to compare with array..

how it is possible??

plz reply..
thanks..

First, as the others have said, Excel is not a DB, and you shouldn't be using it as such.

Second of all, this is an SQL question, not a Java/JSP/JDBC question. Next time, find an SQL forum.

.... where HR IN ( ....

not

.... where HR = ( ....

Edit: This should, at least, be a valid SQL now. Whether it gives you what you want is another question.

Hi ABhi,
Try Like this...

String hrname="(";
for(int k=0;k<my_arr.length;k++)
{

  hrname+="'"+my_arr[k]+"',";
}
hrname+=")";

for(int i=0;i<my_arr.length;i++)
{
query = "select * from my_table where HR=(select max(HR) from my_table where FirstName not in "+hrname+")";

}

Hi ABhi,
Try Like this...

String hrname="(";
for(int k=0;k<my_arr.length;k++)
{

  hrname+="'"+my_arr[k]+"',";
}
hrname+=")";

for(int i=0;i<my_arr.length;i++)
{
query = "select * from my_table where HR=(select max(HR) from my_table where FirstName not in "+hrname+")";

}

Sorry to break this to you but what you wrote is totally wrong and you are going to do serius damage to the kid who asked for help:

To start with:the first for-loop will end with the command: hrname+="'"+my_arr[k]+"',";
Meaning that after the loop the command: hrname+=")"; will generate this String:
hrname = " ...... ',) " . As you can see the comma before the parenthesis will generate an sql error.

The second for-loop is completely unnecessary. You don't use the index i, and you simply assign to the variable query the same String over and over again.
I think that you don't need the loop and only the assignment:

String query = "select * from my_table where HR=(select max(HR) from my_table where FirstName not in "+hrname+")";

I didn't have time to post the solution in my previous post, so here it is:

String hrname="(";
for(int k=0;k< my_arr.length-1 ;k++)
{
  hrname+="'"+my_arr[k]+"',";
}
if (my_arr.length!=0) {
  hrname+="'"+my_arr[my_arr.length-1]+"'";
}
hrname+=")";

yeah U r correct i have given the basic idea .As ,I'm in a hurry i forgot to remove the second loop.

This article has been dead for over six months. Start a new discussion instead.