<meta http-equiv="Content-Type" content="text/html;
charset=gb2312"><%@ page contentType="text/html;
charset=gb2312" language="java" import="java.sql.*" %>
<JSP:useBean id="DBConn" scope="page" class="conn.DBConnMysql"/>
<% //以下几项请自行修改String server="localhost";
//Mysql 服务器的地址String dbname="test";
//Mysql 数据库的名字String user="root";
//Mysql 数据库的登录用户名String pass="chfanwsp";
//Mysql 数据库的登录密码String port="3306";
//SQL Server 服务器的端口号,默认为1433Connection
conn=DBConn.getConnToMysql
(server,dbname,user,pass,port);
Statement stmt=conn.createStatement
(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
String sql="select * from username";
String sql1="insert into username (uid,pwd) values
("梦想年华","梦想年华")";stmt.executeUpdate(sql1);
ResultSet rs=stmt.executeQuery(sql);while(rs.next())
{out.print("用户名:");out.print(rs.getString("uid")+" 密码:");
out.println(rs.getString("pwd")+"<br>");}
//rs.close();//stmt.close();//conn.close();DBConn.close();%> |