aspose file tools*
The moose likes JDBC and the fly likes insert statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "insert statement" Watch "insert statement" New topic
Author

insert statement

meena latha
Ranch Hand

Joined: Jan 24, 2005
Posts: 219
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
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
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


java amateur
Carol Enderlin
drifter
Ranch Hand

Joined: Oct 10, 2000
Posts: 1364
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 ]
Anna Madhusudhanan Natanagopalan
Greenhorn

Joined: Apr 05, 2004
Posts: 25
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
Amarender Reddy
Ranch Hand

Joined: May 12, 2005
Posts: 54
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

Joined: Jan 24, 2005
Posts: 219
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

Joined: May 12, 2005
Posts: 54
===========================================================================

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

Joined: Jan 24, 2005
Posts: 219
Thanks a lot.....
It is working now
Amarender Reddy
Ranch Hand

Joined: May 12, 2005
Posts: 54
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: insert statement
 
Similar Threads
insert statement
java.sql.SQLException: General error
MySQL Error
Kindly help with the "cannot connect to the database" error
application to application security