首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

困扰小弟我几天的有关问题,高手帮忙(高分求出)

2012-01-22 
困扰我几天的问题,高手帮忙(高分求出)我想实现用户登陆功能,用的是:weblogic8.1+oracle9.0+jbuilder9,首先

困扰我几天的问题,高手帮忙(高分求出)
我想实现用户登陆功能,用的是:weblogic8.1+oracle9.0+jbuilder9,
首先我在oracle下建一个用户然后建一个名为userinfo的表,字段有userid,name
,age,password
然后我写了两个jsp分别为title.jsp
代码为
<%@   page   language= "java "   contentType= "text/html;   charset=GBK "   %>
<html>
<head>
<title>   Untitled   Document </title>
<meta   http-equiv= "Countent-type "     content= "text/html;charset=gb2312 ">
</head> <LINK   href= "hellking.css "   type=text/css   rel=stylesheet>
<body>
<%
        boolean   isLog=false;
        try
        {
                  isLog=((String)session.getAttribute( "isLog ")).equals( "1 ");
        }
        catch(Exception   e)
        {
        }
%>
<table   width= "842 "   align=center   cellpadding=3   cellspacing=1   class=tableborder1>
<tr>
<td   width= "832 "   class=tablebody2> ::
<a   href= "index.jsp   target= "_top "> 首页 </a>
<%if(isLog){%> <a   href= "logout.jsp   target= "_top "> 注销 </a> <%}%> ::
</td> </tr> <tr>
<td   width= "832 "   class=tablebody2>
<%
        if(isLog)
        {
                %>
          欢迎光临!
        <%=session.getAttribute( "name ")%> ,您是第
        <%=session.getAttribute( "userLogCount ")%>
        次登陆,您上次登录的时间是:
        <%=session.getAttribute( "userLastLogTime ")%>
        <%
        }
        else
        {
        %>

<form   name= "form1 "   method= "post "   action= "login.jsp ">
&nbsp;&nbsp;&nbsp;用户名
<input   type= "text "   name= "userID "   size= "15 "   style= "BORDER-RIGHT:#ffffff   1px
groove;BORDER-TOP:#ffffff   1px   groove;FONT:12px   Verdana,Geneva,sans-serif;
BORDER-LEFT:#ffffff   1px   groove;WIDTH:100px;COLOR:#000000;BORDER-BOTTOM:#ffffff
1px   groove;HIGHT:18px;BACKGROUND-COLOR:#DFF1F9 ">
密码
<input   type= "password "   name= "password "   size= "15 "
style= "BORDER-RIGHT:#ffffff   1px
groove;BORDER-TOP:#ffffff   1px   groove;FONT:12px   Verdana,Geneva,sans-serif;
BORDER-LEFT:#ffffff   1px   groove;WIDTH:100px;COLOR:#000000;BORDER-BOTTOM:#ffffff
1px   groove;HIGHT:18px;BACKGROUND-COLOR:#DFF1F9 ">
<input   type= "submit "   name= "Submit "   value= "确定 "
style= "height:20;font:9pt;BORDER-BOTTOM:#cccccc   1px   groove;
BORDER-RIGHT:#cccccc   1px   groove;BACKGROUND-COLOR:#eeeeee ">
</form>
<%
        }
%>
</td>


</tr>
</table>
</body>
</html>
另一个是login.jsp代码为
<!--%@   include   file= "include.inc "%-->
<%@   page   contentType= "text/html;   charset=gb2312 "   %>
<%@   page   import= "java.sql.* "%>
<html>
<head>
<title>   Untitled   Document </title>
<meta   http-equiv= "Content-Type "   content= "text/html;charset=gb2312 ">
</head>
<body>
<%
request.setCharacterEncoding( "gb2312 ");
String   CLASSFORNAME= "oracle.jdbc.driver.OracleDriver ";
String   url= "jdbc:oracle:thin:@localhost:1521:MYORACLE ";
String   User= "user ";
String   Pwd= "user ";
String   id=(String)request.getAttribute( "name ");
String   pwd=(String)request.getAttribute( "password ");
Class.forName(CLASSFORNAME);
Connection   con=DriverManager.getConnection(url,User,Pwd);
Statement   statement=con.createStatement();
String   isCorrect= "select   *   from   student   where   name= "+id+ "and   password= "+pwd+ " ";
ResultSet   result=statement.executeQuery(isCorrect);
session.setAttribute( "isLog ",new   String( "0 "));
if(!result.next())
{
        response.sendRedirect( "index.jsp ");
        result.close();
        statement.close();
        con.close();
}
else
{
        //session.setAttribute( "userid ",result.getString( "userid "));
        session.setAttribute( "name ",result.getString( "name "));
        session.setAttribute( "age ",result.getString( "age "));
    //     session.setAttribute( "phone ",result.getString( "phone "));
        //session.setAttribute( "city ",result.getString( "city "));
        //session.setAttribute( "isLog ",new   String( "1 "));
        //int   count=result.getInt( "userLogCount ");
        //session.setAttribute( "userLogCount ",new   Integer(count));
        //count++;
        //java.util.Date   time1=new   java.util.Date();
      //   String   sqltime=new   Timestamp(time1.getTime()).toString();
      //   statement.execute( "update   user_info   set   userLogCount= "+count+ ",userLastLogTime= "+sqltime+ "   where   userID= "+id+ " ");
        statement.close();
        con.close();
        response.sendRedirect( "cxhome.jsp ");
}
%>
然后我一登陆就出现了这样的错误;我初学jsp看不懂
Error   500--Internal   Server   Error  
java.sql.SQLException:   ORA-00933:   SQL   }?cn觃

at   oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at   oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at   oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at   oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)
at   oracle.jdbc.ttc7.TTC7Protocol.parseExecuteDescribe(TTC7Protocol.java:877)


at   oracle.jdbc.driver.OracleStatement.doExecuteQuery(OracleStatement.java:2513)
at   oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2857)
at   oracle.jdbc.driver.OracleStatement.executeQuery(OracleStatement.java:640)
at   jsp_servlet.__login._jspService(__login.java:138)
at   weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at   weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at   weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at   weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:446)
at   weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at   weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at   weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at   weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at   weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at   weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at   weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at   weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
 
高手帮忙,怎么回事


[解决办法]
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134),要么是SQL有问题,要么就是库有问题,你可以先把SQL打出来在PL/SQL里调试一下,如果没问题,有数据的话,那应该是oracle库有问题,可能是驱动的问题,做个简单的测试吧
[解决办法]
SQL命令没有正确结束
String isCorrect= "select * from student where name= "+id+ "and password= "+pwd+ " ";

你打出这个字符串 直接到数据库执行下 可不可以
好象应该是
String isCorrect= "select * from student where name= ' "+id+ " 'and password= ' "+pwd+ " ' ";

热点排行