Hi,
I have a simple jsp site and
use a the "jdbc
racle:thin" driver as connection to the Database.
<%@ page contentType="text/html" language="java"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<sql:setDataSource driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:xe" user="JamesBond"
password="topsecret" />
It works to query some information form the database and print it to the html page:
<sql:query var="vehicles" sql="select * from vehicles">
</sql:query>
<c:forEach var="vehicle" begin="0" items="${vehicles.rows}">
<option value="${vehicle.id}"
<c:if test="${param.id eq vehicle.id}">selected="selected"</c:if>>
${vehicle.type} ${vehicle.name}</option>
</c:forEach>
But when I try to Insert something to the DB I got some errors.
<sql:query var="res" sql="INSERT INTO DOCKBOOK (DOCKNUMMER, CAT, DOG) VALUES (12, 11, 11);">
</sql:query>
Exception Handler
Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
Exception Details: javax.servlet.ServletException
javax.servlet.jsp.JspException: INSERT INTO DOCKBOOK (DOCKNUMMER, CAT, DOG) VALUES (12, 11, 11);: ORA-00911: invalid character
Possible Source of Error:
Class Name: org.apache.jasper.runtime.PageContextImpl
File Name: PageContextImpl.java
Method Name: doHandlePageException
Line Number: 839
Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
Stack trace:
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:839)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:776)
org.apache.jsp.jamesbond.example_jsp._jspService(example_jsp.java:197)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:334)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:595)
The line 839 does not exist within my code.
Also tried alternatively:
<%
Connection connection = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
connection = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "JamesBond", "topsecret");
Statement statement = connection.createStatement();
String command = "INSERT INTO DOCK (DOCKNUMMER, PERSONAL, KAPAZITAET) VALUES (12, 11, 11);";
statement.executeUpdate(command);
%>
with error:
Description: An unhandled exception occurred during the execution of the web application. Please review the following stack trace for more information regarding the error.
Exception Details: org.apache.jasper.JasperException
Unable to compile class for JSP An error occurred at line: 263 in the jsp file: /jamesbond/example.jsp Generated servlet error: Connection cannot be resolved to a type An error occurred at line: 263 in the jsp file: /jamesbond/example.jsp Generated servlet error: DriverManager cannot be resolved An error occurred at line: 263 in the jsp file: /jamesbond/example.jsp Generated servlet error: Statement cannot be resolved to a type
Possible Source of Error:
Class Name: org.apache.jasper.compiler.DefaultErrorHandler
File Name: DefaultErrorHandler.java
Method Name: javacError
Line Number: 84
Source not available. Information regarding the location of the exception can be identified using the exception stack trace below.
Stack trace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:414)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:305)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:767)
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:697)
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:889)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
java.lang.Thread.run(Thread.java:595)
The line 84 is the line is only HTML
Line 263 is the opening "<%" Tag
Does anyone see the problem?