To manipulate data you actually need executeUpdate()
rather than executeQuery()
.
Here’s an extract from the executeUpdate()
javadoc which is already an answer at its own:
Executes the given SQL statement, which may be an INSERT, UPDATE, or DELETE statement or an SQL statement that returns nothing, such as an SQL DDL statement.
Related Posts:
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- java.sql.SQLException: No database selected – why?
- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Eclipse
- java.lang.ClassNotFoundException: com.mysql.jdbc.Driver in Eclipse
- getting error HTTP Status 405 – HTTP method GET is not supported by this URL but not used `get` ever?
- Can’t find mysqladmin on Mac OSX 10.6.8
- DB2 jdbc connection error Connection refused. ERRORCODE=-4499, SQLSTATE=08001
- A JNI error has occurred, please check your installation and try again in Eclipse x86 Windows 8.1
- Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
- DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704
- java.sql.SQLException: Access denied for user ‘root’@’localhost’ (using password: YES)
- ResultSet exception – before start of result set
- java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver Exception occurring. Why?
- IO Error: The Network Adapter could not establish the connection
- Getting java.sql.SQLException: Operation not allowed after ResultSet closed
- How do I get the size of a java.sql.ResultSet?
- SQL Error: 0, SQLState: 08S01 Communications link failure
- How to resolve Unable to load authentication plugin ‘caching_sha2_password’ issue
- Efficient way to do batch INSERTS with JDBC
- What kind of Java type is “[B”?
- Connection Java – MySQL : Public Key Retrieval is not allowed
- JPA or JDBC, how are they different?
- Reverse a string in Java
- Is there any doubly linked list implementation in Java?
- What is a JavaBean exactly?
- Can’t execute jar- file: “no main manifest attribute”
- In a simple to understand explanation, what is Runnable in Java?
- Java – How to use \t in my example [duplicate]
- Android Studio Could not initialize class org.codehaus.groovy.runtime.InvokerHelper
- How Long Does it Take to Learn Java for a Complete Newbie?
- Java JDK – possible lossy conversion from double to int
- Global variables in Java
- java Arrays.sort 2d array
- what is the difference between `public class` and just `class`?
- Copying and modifying array elements
- How to send Https Post request in java
- What is the purpose of a listener in Java?
- stale element reference: element is not attached to the page document
- Error: can only iterate over an array or an instance of java.lang.Iterable
- Why can array constants only be used in initializers?
- Where is Java’s Array indexOf?
- How do I use a delimiter with Scanner.useDelimiter in Java?
- Sort a single String in Java
- Difference between slf4j-log4j12 and log4j-over-slf4j
- Java, “Variable name” cannot be resolved to a variable
- What is Java String interning?
- What condition does while(true) test? When is it true and false?
- What is the significance of log4j.rootLogger property in log4j.properties file? What happens if I don’t use this property?
- “Instantiating” a List in Java? [duplicate]
- HTTP Status 405 – Request method ‘POST’ not supported (Spring MVC)
- Missing `server’ JVM (Java\jre7\bin\server\jvm.dll.)
- imageio.IIOException: Can’t read input file
- Difference between OpenJDK and Adoptium/AdoptOpenJDK
- Compile failed; see the compiler error output for details
- Java: Rotating Images
- Invalid character constant in java
- How to pass a function as a parameter in Java?
- The activity must be exported or contain an intent-filter
- How to set JAVA_HOME environment variable on Mac OS X 10.9?
- Remove last character of a StringBuilder?
- Why SpringMVC Request method ‘GET’ not supported?
- Print a boolean value with printf
- Meaning of @Resource annotation
- How to solve error lossy convertion from int to char?
- What does “error: ‘.class’ expected” mean and how do I fix it
- Printing the stack values in Java
- Import a custom class in Java
- The specified child already has a parent. You must call removeView() on the child’s parent first (Android)
- HTTP Status 500 Error instantiating servlet class
- How to convert the following json string to java object?
- Java end of file
- A KeyValuePair in Java
- Unclosed Character Literal error
- Java error: void cannot be converted to String
- Deleting an object in java?
- Recompile with -Xlint:deprecation for details
- How to determine an object’s class?
- Division of integers in Java
- Consider this code: “int s = 20; int t = s++ + –s;”. What are the values of s and t?
- Reading a .txt file using Scanner class in Java
- “\b” in Java – Windows implemented
- Error: package or namespace load failed for ‘rJava’
- Difference between regex [A-z] and [a-zA-Z]
- How can I convert a char to CharSequence?
- Problems Generating A Math.random Number, Either 0 or 1
- package org.json does not exist when importing org.json.JSONObject
- How to add an element at the end of an array?
- Fields in interfaces
- How to print out all the elements of a List in Java?
- How to send data to COM PORT using JAVA?
- PrintWriter failing to print to file
- char initial value in Java
- What is the difference between local and instance variables in Java?
- Exception in thread “main” java.net.BindException: Address already in use – Error in Netbeans only
- ArithmeticException: “Non-terminating decimal expansion; no exact representable decimal result”
- Return outside method error
- How to define a relative path in java
- Java rules for casting
- No content to map due to end-of-input jackson parser