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.
More Related Contents:
- SQL syntax error in "insert into 'keys'(a,b,c,d,e) values(?,?,?,?,?)" [closed]
- Hours and seconds are lost when storing a date in the database [closed]
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
- Solving a “communications link failure” with JDBC and MySQL [duplicate]
- Java: Insert multiple rows into MySQL with PreparedStatement
- Handling MySQL datetimes and timestamps in Java
- Closing JDBC Connections in Pool
- No suitable driver found for ‘jdbc:mysql://localhost:3306/mysql [duplicate]
- com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link failure [duplicate]
- “Loading class com.mysql.jdbc.Driver … is deprecated” message
- Java JDBC Access denied for user [closed]
- Retrieve an Image stored as BLOB on a MYSQL DB
- Can I execute multiple queries separated by semicolon with MySQL Connector/J? [duplicate]
- runtime error: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
- JDBC returning MySQLSyntaxError Exception with correct statement
- mysql prepared statement error: MySQLSyntaxErrorException
- ‘0000-00-00 00:00:00’ can not be represented as java.sql.Timestamp error
- Problems reading/writing UTF-8 data in MySQL from Java using JDBC connector 5.1
- SQL Error: 0, SQLState: 08S01 Communications link failure [duplicate]
- MySQL connector error “The server time zone value Central European Time” [duplicate]
- com.mysql.jdbc.PacketTooBigException
- com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server [duplicate]
- Should a database connection stay open all the time or only be opened when needed?
- How to correctly write UTF-8 strings into MySQL through JDBC interface
- Glassfish Admin Console throws java.lang.IllegalStateException when creating JDBC Pool
- A datetime equivalent in java.sql ? (is there a java.sql.datetime ?)
- Performance of MySQL Insert statements in Java: Batch mode prepared statements vs single insert with multiple values
- A persistent connection with JDBC to MySQL
- JDBC MySQL connection using Unix Socket
- JDBC connection error : unrecognized timezone [duplicate]