忙了一天,感谢google,baidu,csdn 虽然只是小问题 但是很激动 happy~
首先需要sqljdbc.jar
然后<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.sql.*"%>
<html><body>
<%Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();}
catch(Exception e){out.print(e);}
try{
String uri="jdbc:microsoft:sqlserver://127.0.0.1;DatabaseName=office";
String user="sa";
String password="";
con=DriverManager.getConnection(uri,user,password);
sql=con.createStatement();
rs=sql.executeQuery("select * from member where name=8");
while(rs.next())
{out.print(rs.getString(1));
out.print(rs.getString(2));
}
con.close();
}catch(SQLException e1){
out.print(e1);
}
%>