How do I translate a MySQL query's ResultSet into an integer?
<p>I am not fluent in Java, and JavaScript.</p>

<p>What I am doing is working with a java plugin that allows me to add javaScript into a text file to be called upon on certain events. The JS in the text file can also call upon things inside of the Java Plugin itself giving it access to an API that I don't have documentation for.</p>

<p>What I need to do with my JS is query a MySQL database and get the User Id from a table. Here is my code:</p>

<pre><code>var host = "localhost"
var port = "3306"
var database = "dev"
var user = "root"
var pass = ""
// var username = name of the user used to vote. Part of internal API

function connect(){
  var url = "jdbc:mysql://" + host + ":" + port + "/" + database
  return java.sql.DriverManager.getConnection(url, user, pass)
}
function getUserId(){
  var connection = connect()
  var statement = connection.createStatement()
  var userId = statement.executeQuery("SELECT user_id FROM xf_user_field_value WHERE field_value = '" + username + "'")
  return userId
}
</code></pre>

<p>What this returns is a resultSet. I need it to return is the integer value of the field.. not the result set.</p>

<p>How do I get an integer value from a ResultSet in JavaScript?</p>
