MySQL with JDBC: select * 来自 mysql.proc => FUNCTION * 不存在
MySQL with JDBC: select * from mysql.proc => FUNCTION * does not exist
MySQL 与 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 {...
}
=> 函数 * 不存在
但是 Workbench 给出了正常结果。为什么会这样?
似乎是一条奇怪的错误消息 - 我刚刚用 mysql-connector-java-5.1.34(针对 5.5.42 MySQL 社区服务器)尝试了这个并且它有效(没有例外,但也没有返回行)...
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();
}
}
您的查询字符串是否包含硬空格或其他内容?
更新
您似乎在使用 prepareCall
而不是 prepareStatement
MySQL 与 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 {...
}
=> 函数 * 不存在 但是 Workbench 给出了正常结果。为什么会这样?
似乎是一条奇怪的错误消息 - 我刚刚用 mysql-connector-java-5.1.34(针对 5.5.42 MySQL 社区服务器)尝试了这个并且它有效(没有例外,但也没有返回行)...
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();
}
}
您的查询字符串是否包含硬空格或其他内容?
更新
您似乎在使用 prepareCall
而不是 prepareStatement