title: Java MySQL Update Query
body: <p>I am getting the error "cannot issue data".</p>
  
  <p>Here is the SSCCE</p>
  
  <pre><code>//package mysqltest;
  
  import java.awt.*;
  import java.awt.event.*;
  import javax.swing.*;
  import java.applet.Applet;
  import java.awt.TextArea.*;
  import java.sql.*;
  import java.util.*;
  import javax.swing.plaf.*;
  import javax.swing.plaf.basic.*;
  import java.net.*;
  import java.applet.*;
  
      public class test extends JApplet {
  
        public JTextArea c;
  
        public void init() {
  
            c = new JTextArea();
  
            add(c);
            c.append("Looking for database...");
  
          Connection conn = null;
          Properties props = new Properties();
          String url = "jdbc:mysql://localhost:3306/";
          String dbName = "mystik";
          String driver = "com.mysql.jdbc.Driver";
          String userName = "root";
          String password = "";
          String loggedusername = getParameter("name");
          try {
            Class.forName(driver).newInstance();
            props.put("user", "root");
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mystik", props);
            c.append("\nConnected to the database");
  
  
                          c.append("\nGetting stats for: " + loggedusername);
                          PreparedStatement statement = conn.prepareStatement( "select * from `user` where `username` = '"+loggedusername+"'");
                          ResultSet result = statement.executeQuery();
                          // just a dumb mysql statement!
                          while(result.next())
                          {
                          c.append("\nUsername: "+result.getString(2)+ "\nLevel: "+result.getString(6)+"\nEXP: "+result.getString(8)+"\n");
                          }
  
                          PreparedStatement updateEXP = conn.prepareStatement( "update`user` set `exp` = '666'  where `username` = '"+loggedusername+"'");
                          ResultSet updateEXP_done = updateEXP.executeQuery();
  
                          while(result.next())
                          {
                          c.append("\nUsername: "+result.getString(2)+ "\nLevel: "+result.getString(6)+"\nEXP: "+result.getString(8)+"\n");
                          }
  
  
            conn.close();
            c.append("\nDisconnected from database");
          } catch (Exception e) {
            e.printStackTrace();
          }
  
        }
  
      }
  </code></pre>
  
  <p>and it works... and it's just that <code>update</code> java query doesn't.</p>
  
  <p>Here is what the JTextArea sees:</p>
  
  <pre><code>Looking for database...
  Connected to the database
  Getting stats for: weka
  Username: weka
  Level: 1
  EXP: 1
  </code></pre>
  
  <p>and here is my error:</p>
  
  <pre><code>added manifest
  adding: test.class(in = 2440) (out= 1308)(deflated 46%)
  adding: mysql-connector-java-5.1.13-bin.jar(in = 767492) (out= 735869)(deflated
  4%)
  
  Warning:
  The signer certificate will expire within six months.
  java.sql.SQLException: Can not issue data manipulation statements with executeQu
  ery().
          at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
          at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:989)
          at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:984)
          at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:929)
          at com.mysql.jdbc.StatementImpl.checkForDml(StatementImpl.java:436)
          at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:
  2176)
          at test.init(test.java:53)
          at sun.applet.AppletPanel.run(AppletPanel.java:424)
          at java.lang.Thread.run(Thread.java:619)
  </code></pre>
  
  <p>Lastly, here is how i compile using a .bat file.</p>
  
  <pre><code>@ECHO OFF
  C:
  CD \wamp\www\mystikrpg\mysqltest
  javac -cp mysql-connector-java-5.1.13-bin test.java
  jar cvf mysqlTry.jar test.class mysql-connector-java-5.1.13-bin.jar
  jarsigner -keystore dankey -storepass soccer -keypass soccer mysqlTry.jar gamerpg
  appletviewer -J-Djava.security.policy=game.policy mysqltry.html
  </code></pre>
  
  <p>How do I fix this error? 
  Thanks.</p>