jsp注测得问题,大哥大姐求助(2)

来源:百度知道 编辑:UC知道 时间:2024/06/22 10:55:39
2。我的信息插入不到数据库中。我用的是sql sever2000数据库,纯JDBC数据源,sp4和三个jar文件也能弄了,我的文件放到了d盘,然后通过tomcat的http://localhost:8080/admin/frameset.jsp设定的数据源的。没有修改server.xml.书上说用那样子不用修改server.xml所以就没有修改
请各位指教:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<%!public String codeToString(String str)
{ String s = str;
try
{
byte tempB[] = s.getBytes("ISO-8859-1");
s=new String(tempB);
return s;
}
catch(Exception e)
{
return s;
}
}%>
<% String username= codeToString(request.getParameter("username"));
if(username == null)
username="";
String password= codeToString(request.getParameter("password"));
if(password == null)
password="";
Str

request.getParameter()本身返回的就是String 类型,干吗要用函数获取??岂不是多此一举...

还有 insert 语句是这么写的么??

insert into 表名 values(字段1, 字段2,....);好象不是你那么写的吧

既然你要获取这么多的数据,干吗不把这些数据包装成一个javabean呢

public class User {
private String userId;
private String userName;
private String userPassword;
private String userTrueName;
private String userSex;
private String userAddress;
private String userTelephone;
public User() {
super();
}

public User(String userId, String userName, String userPassword,
String userTrueName, String userSex, String userAddress,
String userTelephone) {
super();
this.userId = userId;
this.userName = userName;
this.userPassword = userPassword;
this.userTrueName = userTrueName;
this.userSex = userSex;
this.userAddress = userAddress;
this.userTelephone = userTelephone;
}

public String getUserAddr