• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

I can select, insert, update but not delete.. please help

 
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody,

My problem is that I can Isnert, Update, and Select from my databse but canot delete. I get always this Exception when I try to delete:


This is the code when the query is submitted:

And this is my DatabaseConnection class:


Could someone please hlep me???
 
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See the exception itself tells you where is the error is.
Whats the SQL you are using to delete from a table ?
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Romaysa,

There are many system.out.println in your program.
can you tell us which one is last system.out printed to ccnsole.

and what is the delete query formed by your program.

thanks
 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my Sql Query:
String deleteQuery= "DELETE "+
"FROM irn_gebruiker "+
"WHERE gebruikersnaam ='" +deletedGeb+"';";

This is the printed query in my consoll:
===== De gebruikers is succesvol verwijderd: Test 22 DELETE FROM irn_gebruiker WHERE gebruikersnaam ='Test 22';

Test 22 is the selected User which I want to delete.
[ January 07, 2005: Message edited by: Azz Romaysa ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Azz Romaysa:
This is my Sql Query:
String deleteQuery= "DELETE "+
"FROM irn_gebruiker "+
"WHERE gebruikersnaam ='" +deletedGeb+"';";



Is that ";" really needed.
 
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think the ; at the end of the statement is only needed in the mysql console but not in JDBC. try without.

pascal
 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It stills give the same Exception:

 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friend,

Do this , write the Delete SQl statement and execute it manually , in a tool like TOAD or SQL console.
If it works format the same delete statement in java code , but without ";"
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think I found the errror

Check the line

ResultSet rs = conn.getInformation("deleteQuery", 0);


this line should be written as

ResultSet rs = conn.getInformation(deleteQuery, 0);

instead of passing delete query variable you are passing a string as "deleteQuery" in getInformation method.

please verify same and revert

thanks

Shailesh
[ January 07, 2005: Message edited by: Shailesh Chandra ]
 
Azz Romaysa
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shailesh,

I don't know how should I thank you....
Yes that was the fout... I was blind that I couldn't see it.
It works now great.

Thank you very very much.
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shailesh Gud work well done .
Where r u from ?
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We all learn by mistakes

cheers Shailesh
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks srini....

I had sent you a personal messsage about me, by the way I am from Delhi

Shailesh
[ January 07, 2005: Message edited by: Shailesh Chandra ]
 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Shailesh Chandra:
thanks srini....

I had sent you a personal messsage about me, by the way I am from Delhi

Shailesh

[ January 07, 2005: Message edited by: Shailesh Chandra ]



Shailesh Do you remember couple of days back i also made a silly, bloody ( sorry for using this word ) mistake , you found that out !!
This happens ... We have to correct it.
 
Shailesh Chandra
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes I remember.
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic