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

Stored Procedure with parameter using INSERT INTO Not working

 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I have a text box and a button in a JFrame Form. When the user enter a name in the text box and click the button.I first connect to the database and called a stored procedure named: "insertName" and passed the stored procedure the textbox value as parameter and tell it to stored it in a table called "Name". Btw i know i can do it direcly by using preparedStatement and changing the string reference variable to "INSERT Statement" but i want to do it by stored procedure.

Netbean don't give me any error or exception but my SQL 2008 profiler trace is saying something like this:


declare @p1 int
set @p1=1
exec sp_prepexec @p1 output,N'@P0 nvarchar(4000)',N'EXEC insertName @P0 ',N'test'
select @p1

As you can see above: the value "test" i entered in the textbox is being passed but i don't understand why it is not working





 
raghav singh
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tools i am currently using:
netbean 8.02 , jdk 1.8 and sql server 2008 with windows 7 64-bit

Oh i forgot....Here is the jdbcUtil class in case someone want to know:

 
raghav singh
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So no one know what the problem with my code???
 
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What happens when you run that stored procedure directly, through the management studio?
 
raghav singh
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:What happens when you run that stored procedure directly, through the management studio?



It says "Command(s) completed successfully." When i created the procedure.

Also i just try this EXEC insertName 'test'. The test value is stored in the table "Name" in the column name correctly.
 
Dave Tolls
Rancher
Posts: 4801
50
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK.
Next possibility is that there's a version mismatch between the DB and the JDBC driver?
I'm not as up with SQL Server as other DBs, but that's something that might be worth checking.

Then again, if SQL Server is receiving the call, apparently correctly, then that's unlikely.

Have you tried committing?
You may not be on auto-commit.
 
raghav singh
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:OK.
Next possibility is that there's a version mismatch between the DB and the JDBC driver?
I'm not as up with SQL Server as other DBs, but that's something that might be worth checking.

Then again, if SQL Server is receiving the call, apparently correctly, then that's unlikely.

Have you tried committing?
You may not be on auto-commit.



Man you are a genius and i am an idiot. YEAH IT WORK. I JUST NEEDED TO SET "conn.commit();"
 
I miss the old days when I would think up a sinister scheme for world domination and you would show a little emotional support. So just look at this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic