Rewrite the title to: By getting the id of the ResultSet and returning it as a java.sql.Array
P粉905144514
P粉905144514 2023-09-03 18:10:50
0
1
372
<p>I have the following:</p> <pre class="brush:scala;toolbar:false;"> def getIds(name: String): java.sql.Array = { val ids: Array[Integer] = Array() val ps: PreparedStatement = connection.prepareStatement("SELECT id FROM table WHERE name = ?") ps.setString(1, name) val resultSet = ps.executeQuery() while(resultSet.next()) { val currentId = resultSet.getInt(1) ids: currentId } return connection.createArrayOf("INTEGER", ids.toArray) } </pre> <p>My intention is to use the output of this method into another PreparedStatement, using <code>.setArray(1, <array>)</code></p> <p>But I get the following error: <code>java.sql.SQLFeatureNotSupportedException</code></p> <p>I'm using MySQL. Already tried INTEGER, INT, BIGINT. But all failed. </p>
P粉905144514
P粉905144514

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!