|
Below you will find a sample JSP that I ran and tested against our AS/400. I am assuming the JDBC drivers are already loaded in your 400 and proper CLASSPATHs are set. You have a DB2 table available to test this JSP. Useful URLs: http://publib.boulder.ibm.com/pubs/html/as400/ic2924/info/java/INDEX.HTM http://publib.boulder.ibm.com/pubs/html/as400/ic2924/info/java/rzaha/devkit.htm <html> <head> <title>Java Server Pages on the AS/400 accessing DB2</title> </head> <%@ page import="java.sql.*" %> <body> <h2>AS400 DB2 Dummy Users List:</h2> <% Class.forName("com.ibm.db2.jdbc.app.DB2Driver"); Connection conn = DriverManager.getConnection("jdbc:db2://as400servername","username","password"); Statement stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * from LIBRARYNAME.tblDummy"); out.print("<table border='1'>"); out.print("<th>ID</th><th>Login</th><th>Description</th>"); while (rs.next()) { String userID = rs.getString("USERID"); String userLogin = rs.getString("Login"); String userDesc = rs.getString("Description"); out.print("<tr>"); out.print("<td>" + userID + "</td>"); out.print("<td>" + userLogin + "</td>"); out.print("<td>" + userDesc + "</td>"); out.print("</tr>"); } out.print("</table>"); conn.close(); %> </body> </html>
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.