Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your <code>SQLException</code> clearly states that:</p> <blockquote> <p>You need to specify <code>Statement.RETURN_GENERATED_KEYS</code> to the <code>Statement.executeUpdate()</code> or <code>Connection.prepareStatement()</code>.</p> </blockquote> <p>This can be achieved as follows (adding an additional value on <code>Connection.prepareStatement()</code> method):</p> <pre><code>String SQL = ""; //whatever my String is PreparedStatement ps = connection.prepareStatement(SQL, Statement.RETURN_GENERATED_KEYS); ps.setString(1, "value"); //Other necessary ps.setXXX() methods //now update ps.executeUpdate(); ResultSet rs = ps.getGeneratedKeys(); </code></pre> <p>The <code>Statement.RETURN_GENERATED_KEYS</code> is key here.</p> <p>Hope this helps!</p> <p>PS: <a href="https://stackoverflow.com/questions/4224228/preparedstatement-with-statement-return-generated-keys">Useful resource</a>.</p> <hr> <p>@Charlie berg, since you prefer being lazy, I changed line 13 of your code to include the <code>Statement.RETURN_GENERATED_KEYS</code>:</p> <pre><code>ps = con.prepareStatement("INSERT INTO characters (level, fame, str, dex, luk, `int`, exp, hp, mp, maxhp, maxmp, sp, ap, gm, skincolor, gender, job, hair, face, map, meso, hpMpUsed, spawnpoint, party, buddyCapacity, messengerid, messengerposition, mountlevel, mounttiredness, mountexp, equipslots, useslots, setupslots, etcslots, monsterbookcover, watchedcygnusintro, vanquisherStage, dojopoints, lastDojoStage, finishedDojoTutorial, vanquisherKills, matchcardwins, matchcardlosses, matchcardties, omokwins, omoklosses, omokties, givenRiceCakes, partyquestitems, jailtime, accountid, name, world) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS); </code></pre> <p>Also, <code>Statement</code> class is of package <code>java.sql</code> (make sure you import correctly). :-)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload