title: Retrieving Primary Key Generated By Trigger (Java)
body: <p>Here's what I'm attempting to do.  I have a Java program that decomms a telemetry stream into the individual raw fields.  I am passing these raw fields values into a MySQL table where each column is one of the fields.  In this database I also have a view that grabs all the telemetry data and calculates a few new derived columns based on raw data (e.g. raw counts to engineering units).  In my Java program, after insertion I would like to grab the corresponding row from the VIEW (raw + derived) and pass that data along elsewhere.</p>
  
  <p>Originally I thought I could simply insert the raw data into the VIEW and have the row returned to me in a ResultSet in the Java program.  Unfortunately the data isn't returned in a ResultSet.</p>
  
  <p>What I'm attempting to do now is insert the raw data into the table (this part works), get the primary key, then lookup the row from the VIEW.  The part I'm struggling with is retrieving the primary key from the INSERT.  I'm using a PreparedStatement generated from my Connection object and have supplied it with Statement.RETURN_GENERATED_KEYS.  However, when I call getGeneratedKeys() on my statement after I call executeUpdate() my ResultSet is always empty.  I can watch it insert the rows into the table while it's running...what am I doing wrong?</p>
  
  <p>Can I not retrieve the generated primary key in this fashion if the primary key is generated via a trigger?</p>
  
  <p>UPDATE: I've tried swapping out the Statement.RETURN_GENERATED_KEYS for a String array with the name of the primary key column, but that doesn't seem to work either.</p>
  
  <p>I apologize for not including my code, but it would be difficult for me to do so.  I've attempted to describe what I'm doing to the best of my abilities.</p>