下面是jsp中的SQL语句。如您所见,我想显示我的SQL结果,但未能这样做。我相信我的方法是错误的。请帮帮我。
Connection connection = null;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "oracle");
Statement statement = connection.createStatement();
String query ="SELECT COUNT(CATEGORY) AS COUNTER FROM CLASSIFY WHERE CATEGORY='REMEMBER'";
ResultSet rst =statement.executeQuery(query);
String counteRemember= rst.getString("COUNT");
out.println(counteRemember);
}
catch(ClassNotFoundException e)
{
out.print("error1");
}
catch (SQLException e)
{
out.print("error2");
}
答案 0 :(得分:0)
进行以下更改并尝试:
while(rst.next()){
String counteRemember= rst.getString("COUNTER");//because "COUNT" is not a column name here..
}