This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

insert statement is not working

 
deepak mehta
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

insert statement is not working it is not giving any error
it giving correct result when i giving select statement
thanks
from
deepak mehta
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

nsert statement is not working it is not giving any error
it giving correct result when i giving select statement

I'm confused - you say the insert is not working, but you can select the data as expected? Can you explain?
 
Smitesh Shinde
Ranch Hand
Posts: 45
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak,
What is the values printed when you do

If it is non-zero then definitely your insert statement is working. I guess
it giving correct result when i giving select statement

means when you execute select you can actually see the data which you are trying to insert. If this is the case how can you say that your insert statement is not working?
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Sturrock wrote:

nsert statement is not working it is not giving any error
it giving correct result when i giving select statement

I'm confused - you say the insert is not working, but you can select the data as expected? Can you explain?


I think he means that when he uses the commented out "select" statement in his code, he gets some results. In other words, his connection works.

This code works fine for me. The only thing I can think of is that you are trying to insert a duplicate key and are somehow not seeing the error message.
 
wang lei
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the reason for this error?
 
deepak mehta
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
select statement is working
connection made to database successfully but when i inserting it is returning n=1 but when i saw in the database for changes no changes occured in database table
please please solve it
from
Deepak Mehta
 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
deepak mehta wrote:select statement is working
connection made to database successfully but when i inserting it is returning n=1 but when i saw in the database for changes no changes occured in database table
please please solve it
from
Deepak Mehta


is it possible that these transactions are not being committed? This used to happen to me sometimes that the insert would run and I'd check it with a select and not see the new data.... and then remember to issue a commit.
 
prasenjitkumar das
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try class loader with "newInstance()" method.

i.e.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();

Regards,
Prasenjit
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
prasenjit.svnit das wrote:try class loader with "newInstance()" method.

i.e.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();

Regards,
Prasenjit

Why?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic