Got trouble with Postgresql & JSP

如果您覺得您的問題不屬於 debian desktop 或是 debian server 版的範圍內,請在這裡發問。

版主: mufa

Got trouble with Postgresql & JSP

文章kiko555 » 週一 3月 08, 2004 7:11 pm

My install list:
Postgresql 7.3.5
Postgresql-jdbc3-7.3
Apache 2.0.48-r1
Tomcat 4.1.24-r1

Everything with the install is OK!
And then I can see the port 8080 is work fine....

But when I try to make the JSP connect with my postgresql server...
I got trouble....
It's the error message...
代碼: 選擇全部
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: 9?:  parser: parse error at or near "user" at character 15

   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
   at java.lang.Thread.run(Thread.java:536)

root cause

javax.servlet.ServletException: 9?:  parser: parse error at or near "user" at character 15

   at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
   at org.apache.jsp.test_jsp._jspService(test_jsp.java:79)
   at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2415)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
   at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
   at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
   at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
   at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:594)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
   at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
   at java.lang.Thread.run(Thread.java:536)

Apache Tomcat/4.1.24


and it's my JSP source code
代碼: 選擇全部
<%@ page contentType="text/html; charset=big5" language="java" import="java.sql.*"%>
<html>
<head>
<title>Test for jdbc on postgresql</title>
</head>
<body>
<%
Class.forName("org.postgresql.Driver");
//Connection con = DriverManager.getConnection("jdbc:postgresql:qpage,qpage,qpage1234"); //connect to the db
String url="jdbc:postgresql://localhost/qpage";
String user="qpage";
String password="";
Connection con= DriverManager.getConnection(url,user,password);
//Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmt = con.createStatement();
ResultSet rs;
rs=stmt.executeQuery("select * from user");

/*    if (rs != null)
    {
      while (rs.next())
      {
        System.out.println("code = "+rs.getInt("Number")+"\n");
      }
    }*/
//    rs.close();
    stmt.close();
    con.close();
%>
</body>
</html>


I can run the same code in the termination command line....
so the postgresql is work well......

Anyone know How can I do with this trouble....
kiko555
可愛的小學生
可愛的小學生
 
文章: 8
註冊時間: 週四 8月 28, 2003 4:13 pm

re:Got trouble with Postgresql & JSP

文章訪客 » 週一 3月 08, 2004 8:06 pm

Exception 顯示的行號與 JSP Source Code 不太一致?
有些時候
試試把 tomcat 停下來,刪除 tomcat 目錄中那些 JSP 生成的 class 檔,重新跑一次,然後再來瞧瞧怎麼回事。

BTW,這個問題偏向 Java 程式設計,應該與作業系統沒關係,不過你的系統是 Debian 嗎?

have fun.
訪客
 

re:Got trouble with Postgresql & JSP

文章kiko555 » 週二 3月 09, 2004 12:03 pm

我有試著先將tomcat 停下後,進入 tomcat/work/Standalone/localhost/
將所有的*.class都刪除,然後再起動tomcat.....
但.....再跑那個網頁,一樣是同樣的錯誤訊息,
進到/work/Standalone/localhost/的目錄下看,只有一個class檔生成..
就是我所執行的那個jsp...

另外...我在/work/Standalone/localhost/目錄下所看到的檔名不大一樣...
我寫的那個jsp檔叫做test.jsp
但~我在目錄下看到的卻是test_jsp.java 和 test_class.class
試了幾次都是一樣...

^^你猜對了~我不是Debian的系統...
kiko555
可愛的小學生
可愛的小學生
 
文章: 8
註冊時間: 週四 8月 28, 2003 4:13 pm

re:Got trouble with Postgresql & JSP

文章訪客 » 週二 3月 09, 2004 5:44 pm

org.apache.jasper.JasperException: 9?: parser: parse error at or near "user" at character 15
這個是指..... :crying:
資料庫看不懂....
所...我在postgresql下select * from user....
一樣是同樣的訊息....
因此判定為資料庫不能接受user or u 這樣的字當table名???
有這種事???
不過當我試著用別的table名後就可以運作,而不出現錯誤訊息了....

但.....怪異的事又發生了.......
居然不能寫出任何資料到畫面上???
只有那些html tag可以出來,但中間撈資料的部份都出不來@@
訪客
 

re:Got trouble with Postgresql & JSP

文章kiko555 » 週二 3月 09, 2004 6:03 pm

= =搞定了....
原來是.....我不小心下了system.out.print....><!
所以寫到終端機了.....(應該是吧)

所以用out.print就可以輸出了.. :-o
kiko555
可愛的小學生
可愛的小學生
 
文章: 8
註冊時間: 週四 8月 28, 2003 4:13 pm

re:Got trouble with Postgresql & JSP

文章訪客 » 週二 3月 09, 2004 8:57 pm

:-o 如果是資料庫,怎麼會是 javax.servlet.ServletException ? 我本來還猜該不會是甚麼奇怪的 taglib 在作怪
any way, 可以輸出就行了 :shock:

have fun.
訪客
 


回到 debian misc

誰在線上

正在瀏覽這個版面的使用者:Google [Bot] 和 1 位訪客