<%@ page language="java" contentType="text/html; charset=gb2312" %>
<%@ page import="java.sql.*"  %>
<html>
  <head>
 
    <title>sql2000</title>
   
  </head>
 
  <body>
    <%
    try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
}
catch(java.lang.ClassNotFoundException e)
{
System.out.println("ClassNotFoundException:");

System.out.println(e);

}
catch (InstantiationException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IllegalAccessException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}

try
{
String url="jdbc:microsoft:sqlserver://192.168.1.248:1433;DatabaseName=richpos";
Connection con=DriverManager.getConnection(url,"sa","");
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery("select * from bshopitem");//(2)发送SQL语句到数据库中
while(rs.next())
{
String shopid=rs.getString("shopid") ; //(3)处理数据并查询结果。
String icode=rs.getString("icode");
String vcode=rs.getString("vcode");
out.println("店代码:"+shopid+",商品代码:"+icode+",厂商代码:"+vcode+"<br/>");
}
rs.close(); //(4)关闭
stmt.close();
con.close();
}
catch(SQLException ex)
{
out.println("SQLException: " + ex.getMessage());
}


%>
  </body>
</html>