有谁知道在Struts中如何连接mysql数据库?要加载哪几个jar?谢谢~~~~~
解决方案 »
- 超出内存的MYSQL错误
- MySQL 随机不重复ID
- mysqlbinlog 还原的局限性
- mysql如何创建一个远程登陆的快捷方式
- mysql在like中关键字设定的问题
- mysql---附加下载的数据库,谢谢!
- 我的MySql4.1.0-Alpha为什么不能修改密码?
- 奇怪,定义了两个字段t1(char 20) t2(varchar 255),建表后t1自动变成了varchar类型,这是为什么?能解决吗?
- mysql 存储过程问题
- You have an error in your SQL syntax; check the manual that corresponds to your
- 下面这个情况如何解决
- mysql5.1中文手册
<%@ page import="java.sql.*" %>
<jsp:useBean id="sqltest" class="database.sqlbean" scope="page">
</jsp:useBean>
<html>
<head>
<title>认证码验证页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
</head>
<body>
<%
String rand = (String) session.getAttribute("rand");
String input =(String) session.getAttribute("input");
String user_name= (String) session.getAttribute("user_name");
String pass_word= (String) session.getAttribute("pass_word");
%>
系统产生的认证码为:
<%= rand %><br>
您输入的认证码为:
<%= input %><br>
<font color=green>验证码输入相同,认证成功!</font><br>
<br>
您输入的用户名为:
<%= session.getAttribute("user_name") %><br>
密码为:
<%= session.getAttribute("pass_word") %><br><%
String permit;
ResultSet rs=null;
String SqlString="select * from UserInfo where username='"+user_name+"'and password='"+pass_word+"'";
try
{
//设置连接
sqltest.setConnection("com.microsoft.jdbc.sqlserver.SQLServerDriver","jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=login","sa","");
//设置SQL语句
sqltest.setQuerystatement(SqlString);
//得到查询结果
rs=sqltest.getResult();
if (rs.next())
{
out.print("登陆成功");
//获得用户的权限
permit=rs.getString("permit");
if (permit.equals("1"))
{
out.println(":你的权限是管理员组");
}
else
{
out.println(":你的权限是用户组");
}
}
else
{
out.print("登陆失败,用户名或密码错");
}
}
catch(SQLException e1)
{
out.print("SQL异常!");
}%>
</body>
</html>