here is one very smaple example.
<%@¡¡page¡¡import="java.lang.*,¡¡java.io.*, ¡Â¡java.sql.*,¡¡java.util.*"¡¡contentType="tex t/html"¡¡%>
<html>
<body>
<%¡¡Class.forName("com.microsoft.jdbc.sqlserver. SQLServerDriver").newInstance();
¡¡¡¡¡¡String¡¡url="jdbc:microsoft:sqlserve r://localhost:1433;DatabaseName=testdb";
¡¡¡¡¡¡String¡¡user="sa";
¡¡¡¡¡¡String¡¡password="password";
¡¡¡¡¡¡Connection¡¡conn=¡¡DriverManager.g etConnection(url,user,password);
¡¡¡¡¡¡Statement¡¡stmt=conn.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_ UPDATABLE);
¡¡¡¡¡¡String¡¡sql="select¡¡id,title¡¡f rom¡¡books";
¡¡¡¡¡¡ResultSet¡¡rs=stmt.executeQuery(sql) ;
¡¡¡¡¡¡while(rs.next())¡¡{¡¡%>
¡¡¡¡¡¡¡¡rs.getString(1)%><br>
¡¡¡¡¡¡¡¡<%=rs.getString(2)%><br>
<%¡¡}¡¡%>
<%¡¡rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
|