Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java executeUpdate won't update!

 
Dave Luling
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I tried to add values in the member table but it won't work. it doesn't show any errors and it says that I'm connected to the database. So why won't it add data to the table? I hope someone can help me.


}
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Dave Luling,

First of all, a warm welcome to CodeRanch!

Dave Luling wrote:So why won't it add data to the table?

You insert a record in table "member" and then you query table "leden"

Kind regards,
Roel
 
Dave Luling
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Roel De Nijs wrote:Hi Dave Luling,

First of all, a warm welcome to CodeRanch!

Dave Luling wrote:So why won't it add data to the table?

You insert a record in table "member" and then you query table "leden"

Kind regards,
Roel


Thanks!

Sorry I'm dutch. In dutch is member called leden. Forgot to change it to english. So that's is not the problem.

Edit: How can I edit my topic?
 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave Luling wrote:Sorry I'm dutch. In dutch is member called leden. Forgot to change it to english. So that's is not the problem.

I'm a southern neighbor of you, so I know "leden" is "member" But didn't know if it was just a typo or (silly) mistake.

Dave Luling wrote:Edit: How can I edit my topic?

I believe you can edit your topic by editing your original post, but I'm not sure. If you can't edit anymore I can do it for you.

On topic: what's the value of the Rows variable?

Some advice:
  • think about java naming conventions (camelCase notation for variables/methods, CamelCase for classes, no underscores)
  • you should always use a PreparedStatement, here is an example


  • Kind regards,
    Roel
     
    Dave Luling
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Roel De Nijs wrote:
    Dave Luling wrote:Sorry I'm dutch. In dutch is member called leden. Forgot to change it to english. So that's is not the problem.

    I'm a southern neighbor of you, so I know "leden" is "member" But didn't know if it was just a typo or (silly) mistake.

    Dave Luling wrote:Edit: How can I edit my topic?

    I believe you can edit your topic by editing your original post, but I'm not sure. If you can't edit anymore I can do it for you.

    On topic: what's the value of the Rows variable?

    Some advice:
  • think about java naming conventions (camelCase notation for variables/methods, CamelCase for classes, no underscores)
  • you should always use a PreparedStatement, here is an example


  • Kind regards,
    Roel


    Hey, buurman!

    I found a tutorial and copied his source. And it works! But can you explain to me why his code works? Because, I don't get it.


     
    Roel De Nijs
    Sheriff
    Posts: 10662
    144
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Dave Luling wrote:I found a tutorial and copied his source. And it works! But can you explain to me why his code works? Because, I don't get it.

    Honestly, I don't have a clue at all! The only (minor) differences I can see:
  • your code use setAutoCommit, but true is the default value (see javadoc), so that should not make any difference
  • your code doesn't have a space between Rank) and values in the insert query (but I doubt if that would be the difference)


  • Another tip: you should definitely use try-with-resources (automatic resource management). It's a very neat new feature of Java 7! An example (which needs some modifications from your side to fit into your code:
     
    Dave Luling
    Greenhorn
    Posts: 6
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Roel De Nijs wrote:
    Dave Luling wrote:I found a tutorial and copied his source. And it works! But can you explain to me why his code works? Because, I don't get it.

    Honestly, I don't have a clue at all! The only (minor) differences I can see:
  • your code use setAutoCommit, but true is the default value (see javadoc), so that should not make any difference
  • your code doesn't have a space between Rank) and values in the insert query (but I doubt if that would be the difference)


  • Another tip: you should definitely use try-with-resources (automatic resource management). It's a very neat new feature of Java 7! An example (which needs some modifications from your side to fit into your code:


    mmm weird. Anyway, I'll check the automatic resource management!

    Thanks!
     
    With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic