jsp登陆数据库oracle的问题?
oracle全局数据库jjgs,sid:jjgs.用户:jtdxdb,密码:jtdxdb,数据库:jtdxdb,表:TDL,字段:ID,PW.具体哪个用的着?数据库:jt...
oracle全局数据库jjgs, sid:jjgs.
用户:jtdxdb, 密码:jtdxdb, 数据库:jtdxdb, 表:TDL, 字段:ID,PW .
具体哪个用的着? 数据库:jtdxdb 也没在代码中体现,到底该怎么做?
问题是下面的代码报错,请大家帮我看下:
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>江苏南京</title>
</head>
<body>
<center>
<h2>系统登陆</h2>
<form action="login.jsp" method="post">
<P>用户名:
<input type="text" name="ID" maxlength=8 style="width:150"><br>
<p>密 码:
<input type="password" name="PW" maxlength=8 style="width:150"><br>
<input type="submit" value="登陆">
<input type="reset" value="取消">
</form>
</center>
</body>
</html>
login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@ page language="java" import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>验证页面</title>
</head>
<body>
<table width="800" align="center" border="0" cellspacing="0" cellpadding="0">
<tr height="200" bgcolor="A1E3F1">
<td>
<%String ID=request.getParameter("ID");
if (ID==null)
{ID="";
}
byte B[]=ID.getBytes("ISO-8859-1"); //这里的b是怎么回事?
ID=new String(b);
String PW=request.getParameter("PW");
if (PW==null)
{PW="";}
byte c[]=PW.getBytes("ISO-8859-1"); //c就不会有下划线?
PW=new String(c);
Connection con=null;
Statement sql=null;
ResultSet rs=null;
try
{Class.forName("oracle.jdbc.driver.OracleDriver"); }
catch(ClassNotFoundException e){}
String url="jdbc:oracle:thin:@192.168.168.52:1521:jjgs"; //jjgs为数据库的SID
String user="jtdxdb";
String password="jtdxdb";
try
{con= DriverManager.getConnection(url,user,password);
sql=con.createStatement();
String condition="select * from TDL where ID=''+ID+''"; //这里后面可不可以这样ID=''+ID+''"; ?
rs=sql.executeQuery(condition);
while(rs.next())
{
String ID=rs.getString("ID"); //ID有错,改什么,怎么改
String PW=rs.getString("PW"); //PW有错
if (PW.trim().equals(PW.trim()))
{out.println("ok");}
}
}
catch(SQLException e){}
%>
</td>
</tr>
</table>
</body>
</html> 展开
用户:jtdxdb, 密码:jtdxdb, 数据库:jtdxdb, 表:TDL, 字段:ID,PW .
具体哪个用的着? 数据库:jtdxdb 也没在代码中体现,到底该怎么做?
问题是下面的代码报错,请大家帮我看下:
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>江苏南京</title>
</head>
<body>
<center>
<h2>系统登陆</h2>
<form action="login.jsp" method="post">
<P>用户名:
<input type="text" name="ID" maxlength=8 style="width:150"><br>
<p>密 码:
<input type="password" name="PW" maxlength=8 style="width:150"><br>
<input type="submit" value="登陆">
<input type="reset" value="取消">
</form>
</center>
</body>
</html>
login.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<%@ page language="java" import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>验证页面</title>
</head>
<body>
<table width="800" align="center" border="0" cellspacing="0" cellpadding="0">
<tr height="200" bgcolor="A1E3F1">
<td>
<%String ID=request.getParameter("ID");
if (ID==null)
{ID="";
}
byte B[]=ID.getBytes("ISO-8859-1"); //这里的b是怎么回事?
ID=new String(b);
String PW=request.getParameter("PW");
if (PW==null)
{PW="";}
byte c[]=PW.getBytes("ISO-8859-1"); //c就不会有下划线?
PW=new String(c);
Connection con=null;
Statement sql=null;
ResultSet rs=null;
try
{Class.forName("oracle.jdbc.driver.OracleDriver"); }
catch(ClassNotFoundException e){}
String url="jdbc:oracle:thin:@192.168.168.52:1521:jjgs"; //jjgs为数据库的SID
String user="jtdxdb";
String password="jtdxdb";
try
{con= DriverManager.getConnection(url,user,password);
sql=con.createStatement();
String condition="select * from TDL where ID=''+ID+''"; //这里后面可不可以这样ID=''+ID+''"; ?
rs=sql.executeQuery(condition);
while(rs.next())
{
String ID=rs.getString("ID"); //ID有错,改什么,怎么改
String PW=rs.getString("PW"); //PW有错
if (PW.trim().equals(PW.trim()))
{out.println("ok");}
}
}
catch(SQLException e){}
%>
</td>
</tr>
</table>
</body>
</html> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询