<%@ page import="java.sql.*" %> <% String connectionUrl = "jdbc:sqlserver://localhost:1433;databasename=AdventureWorks2008R2;user=AdventureWorks;password=AdventureWorks"; Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); Connection con = DriverManager.getConnection(connectionUrl); Statement statement = con.createStatement() ; ResultSet resultset = statement.executeQuery("select Name, GroupName from HumanResources.Department"); %> <% while (resultset.next()){ %> <% } %>
NameGroupName
<%= resultset.getString("Name") %> <%= resultset.getString("GroupName") %>