ÈçºÎÓÃjspÁ¬½Ópostgresql£¿Íò·Ö¸Ðл£¡
ÎÒ¸Õ¸Õ½Ó´¥postgresql£¬²»ÖªµÀÄÜ·ñÓÃjspÁ¬½Ópostgresql¡£ÍøÉÏÏà¹Ø×ÊÁϺÜÉÙ£¬Íû´óϺÃÇÖ¸½Ì£¡Ð¡Å®×Óߵл£¡£¡
ĿǰÎÒ¿´µ½µÄ×éºÏ¶¼ÊÇ£ºPHP+Apache+Postgresql
ÊÇ·ñ¿ÉÒÔÓãºJSP+TOMCAT+Postgresql??
Çë˵ϾßÌå·½·¨£¡£¡Íò·Ö¸Ðл£¡£¡
JSP »òÕß java Á¬½ÓÆäËüÊý¾Ý¿âÄãÊÇÈçºÎʵÏֵģ¿
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("org.postgresql.Driver").newInstance();
String url ="jdbc:postgresql://localhost:5432/dbTest" //dbTestΪÄãµÄÊý¾Ý¿âÃû
String user="postgres";
String password="postgres";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
ÄúµÄµÚÒ»¸ö×Ö¶ÎÄÚÈÝΪ£º <%=rs.getString(1)%>
ÄúµÄµÚ¶þ¸ö×Ö¶ÎÄÚÈÝΪ£º <%=rs.getString(2)%>
<%}%>
<%out.print("Êý¾Ý¿â²Ù×÷³É¹¦!!!");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
²»Ðа¡£¬ÏÔʾÓдíÎó¡£
org.apache.jasper.JasperException: Unable to compile class for JSP.
ÎÒÔÚ»·¾
Ïà¹ØÎÊ´ð£º
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
ÎÒÏë×ö¹»¹ºÎï³µÓÃsession µ«ÊDz»ÖªµÀÔõô»ñÈ¡¹ºÂòÊýÁ¿ ËÓоßÌåµÄ´úÂëÂð Ï£ÍûÄܸîÉá
ÏÂÃæÊǹºÎï³µµÄºËÐÄ´úÂë
ÓÐÁËÕâ¸ö ¾ÍÓ¦¸ÃÄܹ»×ö³öÀ´°É
Java code:
public void doPost(HttpServletRequest reque ......
ÎÊÌâÃèÊö£º
ÀýÈçÎÒÒªÏÔʾµÄÄÚÈÝÈçÏÂËùʾ
Ò»¼¶Ä¿Â¼1
Ò»¼¶Ä¿Â¼1×ÓÀà1
×ÓÀà1
Ò»¼¶Ä¿Â¼1×ÓÀà2
......
ÎÊÌâÊÇÕâÑùµÄ£º
ÎÒÓÐÒ»¸öÎļþnagiv.jsp ÁíÒ»¸öÎļþfailure.jsp°üº¬Ëû£¬Í¬Ê±nagivÎļþÖÐÓÐÒ»¸ö¿ÉÒÔÌø×ªµ½yy.jspµÄcommandButton£¬µ«ÊÇÎÒ½«failureÖеã»÷nagivÖеÄÄĸöcommandButton£¬Ò²Ãæ²»»áÌø×ª ......