Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Delete doubt

 
Megha Rajeevan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers!!
I'm new to java ranch!! here i'm doing some database project in jsp and oracle!! i'm planning to do some administrative privilage ie., only the administrator can edit or delete some datas in the database.. the edit is successful.. but the delete is making me problems..

i've created a jsp page..
in that page.. there is a table...
the first column.. is a check box..
the second column is the record from database
and so on up to 10th column..
_____________________________________________________________________
| check |col1 | col2 |col3 | col4 |
|---------------------------------------------------------------------
| | | | | |
| | | | | |
| | | | | |
|____________________________________________________________________

so.. the datas are displaying like this in the jsp page..
if i want to delete the first and the 5th record..
i check the check box corresponding to that!!

int the check box name.. i'm giving the value for search query!!
like file number!!
and it is passing to another jsp page when i press submit...and deletion takes place..
how can i do that!!

please help ranchers..


if u got the idea..and if u have the code please send me!!
thanks in advance!!
regards megha
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
give same name to all your checkboxes


inside your servlet try

String id[] = request.getParameterValues("recordId");

id array will hold all the selected checkbox values.. this is what i remember at the top of my head.. hope it helps !

Thanks,
Rajeev.
 
Megha Rajeevan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Rajeev!!
Thank u for replying me.. with some good ideas!!
ok.. we can delete using the row id of the table

but how to get the row id

just i'm giving the query like this

if there is any problem please let me know!!
_____________________________________________________________________
tab1.append("select rowid from details");

String query = tab1.toString();
out.println(query);

Statement stmt = dbCon.createStatement();
ResultSet rs = stmt.executeQuery(query);


while(rs.next())
{ String rowvalue = rs.getrowid();
//how can i get?
}
________________________________________________________________________thanks in advance

regards
Megha!!
 
Aravind Prasad
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Megha..
i'm also looking for the same doubt...
if we can get the row id..
then we can particularly delete the row with that row id na

but i don't think it is possible..
y can't u got for a primary key in the table.. i think that may be easier for deleting!! know!!
 
Megha Rajeevan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Aravind!!
But when i created the table i left to give the primary key.. and now abt 100 records are there.. so... if i want to delete one there is duplication orruring.. thatz why.. i need to get the row id..

can any one in the ranchers please help me.. how to get the row id from oracle table

i can execute the query..
select rowid from the table
but i cannot the the values.. from that
for that what should i do!!
i think it is a string value..
we cannot also use.. Result set.. since that is not in the table..
so if u know please help me!!


thanks u..
Regards
Megha
 
Shekhar Singh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Megha Rajeevan:
Hello Medha.

use "select rowid,f1,..fn" query and assign rowid value to checkbox id..
regards
Shekhar
 
Megha Rajeevan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to u very much

thank u ....
i got the answer and i love java ranch forum!!

thank u all ranchers

 
Megha Rajeevan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ranchers!!

Help me please

i'm getting all the values to the jsp page

i'm using request.getParamterValues("test") where test is the checkbox name

String test[] = request.getParameterValues("test");

for(int i=0;i<= test.length();i++)
{out.println(test[i]);
}
but when i give the test.length()
it is showing error!!

how can i fix this problem

thank u ranchers!!
 
Manu Dhanda
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Megha..


test is an array here. check out your length method here.
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Megha Rajeevan:
Hello Ranchers!!

Help me please

i'm getting all the values to the jsp page

i'm using request.getParamterValues("test") where test is the checkbox name

String test[] = request.getParameterValues("test");

for(int i=0;i<= test.length();i++)
{out.println(test[i]);
}
but when i give the test.length()
it is showing error!!

how can i fix this problem

thank u ranchers!!


use test.length instead instead.

i think if u can assign the checkbox name as chkBox_DatabaseColmnValue
DatabaseColmnValue should be in java expression.

while getting in the Servlet with getParameterNames() it will return the control names trim of the control name and get the DatabaseColmnValue and pass to the db ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic