привет, я написал сервлет и его вывод не выводится
мой код
@WebServlet(name="NewServlet", urlPatterns={"/NewServlet"})
public class NewServlet extends HttpServlet {
Connection connection;
ResultSet resultset;
private PreparedStatement updateVotes, totalVotes, results;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, ClassNotFoundException, SQLException {
Class.forName( "org.apache.derby.jdbc.EmbeddedDriver" );
connection = DriverManager.getConnection( "jdbc:derby://localhost:1527/HELLOJI","HELLO","HELLO" );
// TODO output your page here
Statement statement=connection.createStatement();
statement.executeQuery("CREATE TABLE customers(FIRSTNAME char(50),LASTNAME char(50))");
statement.executeQuery("INSERT INTO customer(\"HELLO\",\"HELLO\")");
response.setContentType("text/xml;charset=UTF-8");
PrintWriter out = response.getWriter();
try {
// TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet NewServlet</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Hehjhkhk</h1>");
out.println("</body>");
out.println("</html>");
}
finally {
out.close();
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
processRequest(request, response);
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewServlet.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(NewServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
processRequest(request, response);
} catch (ClassNotFoundException ex) {
Logger.getLogger(NewServlet.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(NewServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
нет исключений classcast или чего-то еще. Потому что, когда я прокомментировал заявление
statement.executeQuery("CREATE TABLE customers(FIRSTNAME char(50),LASTNAME char(50))");
statement.executeQuery("INSERT INTO customer(\"HELLO\",\"HELLO\")");
показывает вывод. Я думаю, что соединение с базой данных идеально, проблема в statement.executeQuery();
Можете ли вы помочь, как справиться с этим исключением.