I run SQL queries from JAVA program (an example is shown below). My question is: Is it possible to run SQL query, if column names are defined in an array and the array size is not known apriori? Thanks!

public void setQuery(String query) {
    try {
      int rs = statement.executeUpdate(query);
    } catch (Exception e) {

Recommended Answers

All 2 Replies

Looks to me to a Java question rather than MySQL. In MySQL you cannot pass arrays as query parameters. You would have to explode your array to a concatenation of column names 'a,b,c' and build a query like "select a, b, c from x..."

Ok, thank you. I've implemented it somehow similar to whar you suggested.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.