[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

JSP Example of DB2 connection page?

Posted on 2005-05-09
5
Medium Priority
?
2,242 Views
Last Modified: 2013-12-10
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.
0
Comment
Question by:g118481
  • 2
3 Comments
 
LVL 7

Accepted Solution

by:
damonf earned 1000 total points
ID: 13977236
<%@ 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
 
LVL 16

Expert Comment

by:suprapto45
ID: 13983899
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
 
LVL 16

Assisted Solution

by:suprapto45
suprapto45 earned 1000 total points
ID: 13983904
Hi,

Or this IBM RedBook is good :).

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

Regards
Dave
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Upgrading Tomcat – There are a couple of methods to upgrade Tomcat is to use The Apache Installer is to download and unzip and run the services.bat remove|install Tomcat6 Because of the App that we are working with, we can only use Tomcat 6.…
There are numerous questions about how to setup an IBM HTTP Server to be administered from WebSphere Application Server administrative console. I do hope this article will wrap things up and become a reference for this task. You need three things…
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question