用SELECT查询数据库就可以了
下面的语句从表中选取 LastName 列的数据:
SELECT LastName FROM Persons
给你个例子
自己再参考一下吧,我用的是sql server
学程序不能全靠别人
<%
Connection conn=null;
Statement sqlStmt=null;
ResultSet rs=null;
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:1433;User=XXX;Password=XXX;DatabaseName=web");
sqlStmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
}
catch(Exception e)
{
System.err.println(e.getMessage());
}
String sql="select * from Table where typeid=1";
try
{
rs=sqlStmt.executeQuery(sql);
while(rs.next())
{
//输出一下内容
out.print(rs.getString(""));
out.print(rs.getString(""));
}
}
catch(Exception ex)
{
System.err.println(ex.getMessage());
}
%>