Reputation: 540
MySQL with JDBC:
select * from mysql.proc
________________________
PreparedStatement selectClientIDsStatement = null;
Connection connection = Db.getConnection();
try {
String query = "select * from mysql.proc";
selectClientIDsStatement = connection.prepareCall(query);
...exception
} catch (SQLException e) {
throw new VeException(e);
} finally {...
}
=> FUNCTION * does not exist But Workbench gives normal result. Why it is like this?
Upvotes: 0
Views: 481
Reputation: 4209
Seems like a strange error message - I just tried this with mysql-connector-java-5.1.34 (against 5.5.42 MySQL Community Server) and it worked (no exception, but also no rows returned)...
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class MySQL {
public static void main(String[] args) throws Exception {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test?user=root&password=root");
Statement statement = conn.createStatement();
ResultSet resultSet = statement.executeQuery("select * from mysql.proc");
while (resultSet.next()) {
System.out.println("GOT A ROW!");
}
resultSet.close();
statement.close();
conn.close();
}
}
Does your query string contain hard spaces or anything??
UPDATE
It looks like you are using prepareCall
instead of prepareStatement
Upvotes: 1