× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.


  • Subject: Re: Servlet using JDBC
  • From: "vijayakumar purushothaman" <p_vijayakumar@xxxxxxxxxxx>
  • Date: Sun, 09 Jul 2000 22:14:31 PDT

Hai Mr.T,
          We are using websphere 1.1 which has been installed in our V4R3. 
Using Jdbc in servlets is same as what we do in java. But we must change the 
driver class and IBM giving two kind of native drivers, Pls go thru this URL 
http://www.as400.ibm.com/developer/jdbc/faqs/jdbcfaq.html

hope it will provide good tips to u. Anyhow as u asked i have attached a pgm 
which is working fine in my system. Kindly give your feedbacks, it will help 
me to correct my mistakes.

Bye,
Vijay.

import java.sql.*;
import java.util.*;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Jdbc_Servelt extends HttpServlet
{

public void doGet(HttpServletRequest req, HttpServletResponse res)
                                throws ServletException, IOException
        {
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;

        res.setContentType("text/html");
        PrintWriter pw = res.getWriter();

        try
                {
                Class.forName("com.ibm.db2.jdbc.app.DB2Driver");

                String system = "My_As/400System_name/My_Library";
                String userId = "My_Profile";
                String password = "My_Password";
                String url = "jdbc:db2://" + system;
                 // Connect using a user id and password.
                conn = DriverManager.getConnection(url,userId, password);

                String sqlString = "SELECT * FROM My_Library.EMPPF";

                stmt = conn.createStatement(); // Execute the query
                rs = stmt.executeQuery(sqlString);

                pw.println("<HTML>");
                pw.println("<HEAD><TITLE>JDBC Results 
servlet_RESPONSE</TITLE></HEAD>");
                pw.println("<BODY>");
                pw.println("<UL>");
                pw.println("<BR>");

                while (rs.next())
                        {
                                int empID = rs.getInt(1);
                                String empName = rs.getString(2);

                                pw.println("Emp ID  : "+ empID + "   "+ "Emp 
Name :  "+ empName + 
"<BR>");

                        }// endof while loop

                pw.println("</UL>");
                pw.println("</BODY></HTML>");

                rs.close();

        } catch (Exception e) { pw.println("Error e : " + e); }

                finally {
                                try
                                 {
                                        if (conn != null)
                                                conn.close();

                                 } catch (SQLException sqlex) {}
                        }// end of connection and finally block..

    }// end of doget block


}// end of class









>From: tmalin@hannasteel.com
>Reply-To: JAVA400-L@midrange.com
>To: "'JAVA400-L@midrange.com'" <JAVA400-L@midrange.com>
>Subject: Servlet using JDBC
>Date: Fri, 7 Jul 2000 14:25:31 -0500
>
>I am trying to run a servlet on WebSphere that accesses files in DB2/400. I
>am not having very much luck, Does anyone have any examples of this type of
>servlet. or information on how to setup the AS/400 environment to run it.
>
>Thanks in advance
>T.
>
>
>
>
>+---
>| This is the JAVA/400 Mailing List!
>| To submit a new message, send your mail to JAVA400-L@midrange.com.
>| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
>| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
>| Questions should be directed to the list owner: joe@zappie.net
>+---

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

+---
| This is the JAVA/400 Mailing List!
| To submit a new message, send your mail to JAVA400-L@midrange.com.
| To subscribe to this list send email to JAVA400-L-SUB@midrange.com.
| To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com.
| Questions should be directed to the list owner: joe@zappie.net
+---

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.