• 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:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

insert statement

 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all...
I am not able to insert the record into the database.
I use able to execute my select statement .
So to check the error i use System.out.println().
Using that i was able to get output just before line 1 .
Below is my code.


My printStackTrace gives the following error


I am not able to locate the error in my insert statement.
Can anybody help me out.
Thanks in advance
Ramya.A
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm really not sure, but since error msg says:

Syntax error in INSERT INTO statement


i guess it might be in your insert statement:

Insert into customerTable
values(FirstName,LastName,Role)



hope this helps
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure why you need to wait for someone else to check your insert statement.

Print out the sql, the values and try it out.

Discussion started over in servlets forum, insert statement.
[ May 15, 2005: Message edited by: Carol Enderlin ]
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is in your insert statement.

you mistyped the key word values as value.(second line in your query)

StringBuffer sql=new StringBuffer("Insert into customerTable(");
sql.append("FirstName,LastName,Role)values(");
sql.append("?,?,?)");

Thanks and regards
Anna Madhusudhanan
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ramya!

you posted the same query in Servlets forum with code. Problem

persists even after the INSERT statement have been corrected. So, to be

sure of everything I insists

==> to check whether the getConnection is declared a static method

==> to check whether the output statements of the getConnection are being

displayed.

==>to override a doGet() or doPost() rather service() method as this could

pose a series of internal problems

cheers
amar
 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks amar......
My getConnection() is declared static only.
I am able to manually enter the value into the data base.
Say for like
String sql = "Insert into EntryTable values('ramya','jp','beach');
where ramya,jp,beach are the value i wanted to insert into the database.

The problem arises when i try to take the data from my html page and then insert into the database.

To make sure whether i am able to get the data from html page i outputted the data in my console using System.out.println().

I was able to get the data output from the html page into my console.
I dont know other than these what are the things i should take care off.
 
Amarender Reddy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
===========================================================================

The problem arises when i try to take the data from my html page and then insert into the database.

===========================================================================

Then it is clear that your HTML is not able to call the concerned servlet

which would interact with the database. Check the web.xml file for this

servlet and also make sure that the action tag of your HTML page points to

the exact location of this srevlet.

cheers
 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot.....
It is working now
 
Amarender Reddy
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,

-----------------------------------------------------------

Thanks a lot.....
It is working now

------------------------------------------------------------

i kindly request one-and-all to please post the solution of the queries

that have been answered through this group. Forum is a family and we need

to share not just our questions but answers also, so that others who have a

similar query will be happpy with the answer.

Thank you.

Regards,
amar
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic