• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Delete doubt

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!!
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Megha..


test is an array here. check out your length method here.
 
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic