JSP Example of DB2 connection page?

Anyone have a JSP page with a DB2 connection in it?
I am using Websphere 5.0 and have created a datasource in the Admin Console.
Thanks in advance for your time.
LVL 1
g118481Asked:
Who is Participating?
 
damonfConnect With a Mentor Commented:
<%@ page import="java.sql.*,javax.sql.*,javax.naming.*"%>
<%
Context c = new InitialContext();
DataSource ds = (DataSource)c.lookup("yourdatasourceJNDIname"); //usually something like "jdbc/myds"
Connection conn = ds.getConnection("user","password"); // or ds.getConnection() will use default user id if you specified it
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("select * from table1");
while(rs.next())
     out.println("column1" + rs.getString(1) + "<br>");
%>
0
 
suprapto45Commented:
Hi,

You can look at the thread here. It explains how to do it. Though it is in Tomcat, it should be similar :).
http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21390788.html

Regards
Dave
0
 
suprapto45Connect With a Mentor Commented:
Hi,

Or this IBM RedBook is good :).

http://publib-b.boulder.ibm.com/Redbooks.nsf/RedbookAbstracts/sg246219.html

Regards
Dave
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.