你这个分不好拿,大概说写方法!1.连接数据库;2.验证用户;3.读取传品表单数据;
1.连接mssql数据库!
package gprs;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class DBManager {
private String driver="sun.jdbc.odbc.JdbcOdbcDriver";
private String url="jdbc:odbc:://loacalhost/webDB?useUnicode=true&characterEncoding=gb2312";
private String username="sa";
private String password="sa123";
public Connection connection =null;
private static DBManager dbManager=null;
private DBManager()
{
try
{
Class.forName(driver);
connection=DriverManager.getConnection(url, username, password);
} catch (ClassNotFoundException e) {
System.out.println("1");
} catch (SQLException e) {
System.out.println("2");
}
}
public static DBManager getDBManager()
{
if (null==dbManager) {
dbManager=new DBManager();
}
return dbManager;
}
}
2.验证用户的jsp
<%@ page contentType="text/html;charset=utf-8" %>
<%@ page import="java.util.*" %>
<%@ page import="gprs.DBManager"%>
<%@page import="java.sql.*" %>