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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

insert statement

 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi all..i am not able to insert the data into my data base.
Below is my code

To find the error line is use System.out.println().
When i used that i was able to get output just before line 1.
After line 1 i am not able to get any output.

But i am able to do my select statement properly.
I am not able to find error in my insert statement.
Please give me some suggestion.

Thanks in advance
Ramya
 
Ranch Hand
Posts: 1087
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Report post to moderator

Originally posted by ramya jp:



i was able to get output just before line 1.
After line 1 i am not able to get any output.



You should have posted this in JDBC forum.

1. are you committing your transaction ?
2. If you can see System.out.println before line 1, Then might be there is an exception during insert.

Did you check what does StatckTrace say ?

you can do this simply



Shailesh
 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks Shailesh.....
As you said i inserted printStackTrace().
So in my console i got the following error message

So from the message it is obvious that there is error in insert statement,but i am not able to knock off the error.
Can u please check my insert statement and tell me whether there is any syntax error.

Thanks
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Report post to moderator
Correct syntax is as below:

INSERT INTO table_name (col1_name, col2_name) VALUES (value1, value2)
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Report post to moderator

Correct syntax is as below:

INSERT INTO table_name (col1_name, col2_name) VALUES (value1, value2)


let me (partly) disagree with you; see this
 
drifter
Posts: 1364
  • Mark post as helpful
  • send pies
  • Report post to moderator
miguel,

not sure what your point is.

 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Report post to moderator
i mean that saying that there's only one correct aproach doesnt seem right to me: if you wanna make an insert with all fields you can simply say
INSERT INTO table_name VALUES (value1, value2) , as that site's tutorial refers:

The INSERT INTO Statement
The INSERT INTO statement is used to insert new rows into a table.

Syntax
INSERT INTO table_name
VALUES (value1, value2,....)

You can also specify the columns for which you want to insert data:

INSERT INTO table_name (column1, column2,...)
VALUES (value1, value2,....)

 
Marshal
Posts: 67279
170
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not cross-post the same question in multiple forums. It wastes people's time when multiple redundant conversations take place.
 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks to all for your response....but still my problem persists.
I am not able to insert the data.
There is my complete code.

The code inside my ConnectionDB class

Will be great if somebody is able to tell me some solution .
Thanks
Ramya
[ May 15, 2005: Message edited by: ramya jp ]
 
That's a very big dog. I think I want to go home now and hug this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!