Skip to content
Advertisement

java netbean inserting data to db does not work

I’m trying to insert data to data base by my own interface using java netbean But I’m stuck with insert query doesn’t work here is my code segment

st.executeUpdate(query) mark as wrong.

Advertisement

Answer

Ok, let me explain your problem.

  1. You don’t have configured jdbc driver.
  2. Don’t need to cast anything!
  3. You have question mark ‘?’ In your query, and you are using simple Statement class to execute instead of PreparedStatement.

Now, if you are using simple Statement, follow this link: A Java MySQL INSERT example (using Statement)

If you are using PreparedStatement, you can follow this link: A Java MySQL INSERT example (using PreparedStatement)

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement