Java School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a Java Expert!

Join 300,456 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,647 people online right now. Registration is fast and FREE... Join Now!




help in passing parameters in sql+ commands using eclipse

 

help in passing parameters in sql+ commands using eclipse, whats wrong in this statement stmt.executeUpdate("delete from tcs

Rating  5
ankitha_ma

21 Jun, 2009 - 10:00 PM
Post #1

New D.I.C Head
*

Joined: 21 Jun, 2009
Posts: 2

i am using oracle sql+ and eclipse for my project on jsp,databases. i have to delete a record based on parameter passed,my code is

CODE

public class  EmpInfoFactory
{
public void delete(int id)

{
    
    Connection conn = null;

    
    DatabaseManager dbManager = new DatabaseManager();
    try{
    conn=dbManager.connectToDatabase();

    Statement stmt = conn.createStatement();
stmt.executeUpdate("delete from tcs_bgc_emp_info where id=@id);
stmt.executeQuery ("select * from tcs_bgc_emp_info ");

ResultSet rset=stmt.getResultSet();  
while (rset.next())
{
    
     System.out.println (rset.getString(1));  
}
rset.close();
stmt.close();
conn.commit();
if(conn!= null)
{
     conn.close();
}
  } catch(Exception e)
  {
      System.out.print(e);
  }
    }
public static void main(String args[])
{
    EmpInfoFactory obj = new EmpInfoFactory();

obj.delete(3);
}
}


its showing error" statement missing"
pls help me...

Mod Edit: Please use code tags when posting your code. Code tags are used like so => code.gif

Thanks,
PsychoCoder smile.gif

This post has been edited by PsychoCoder: 25 Jun, 2009 - 07:41 PM

User is offlineProfile CardPM
+Quote Post


kmangold

RE: Help In Passing Parameters In Sql+ Commands Using Eclipse

25 Jun, 2009 - 04:46 AM
Post #2

D.I.C Head
Group Icon

Joined: 24 Jun, 2009
Posts: 166



Thanked: 7 times
Dream Kudos: 75
My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Please post like this:

Thank you for helping us helping you.
User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: Help In Passing Parameters In Sql+ Commands Using Eclipse

25 Jun, 2009 - 07:41 PM
Post #3

Dyslexics Untie!
Group Icon

Joined: 26 Jul, 2007
Posts: 14,714



Thanked: 501 times
Dream Kudos: 11450
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Moved to Java smile.gif
User is offlineProfile CardPM
+Quote Post

pbl

RE: Help In Passing Parameters In Sql+ Commands Using Eclipse

25 Jun, 2009 - 07:57 PM
Post #4

Java Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 9,537



Thanked: 1126 times
Dream Kudos: 450
My Contributions
You have an unclosed String (a " missing) in your first executeUpdate()
SQL standards say that SQL statement must end with a ; ... some database are more leniant about that but I think (I might be wrong) that Oracle is strict about it. Use PreparedStament they will add the ; for you smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 02:07AM

Live Java Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month