DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old February 29th, 2004, 07:14 PM
Shinto Shinto is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 Shinto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
JSP with DB2

Hi, i cant seem to get DB2 data to display on my JSP page. Is it because of my coding or because for the db2driver? Attached below is a copy of my class file.


package WH;

import java.sql.*;
import java.sql.Statement;

public class DbConnect1 {

private String dbUser = "XXX";
private String dbPasswd = "XXX";
private String dbDriver = "COM.ibm.db2.jdbc.app.DB2Driver";
private String dbURL = "jdbc:db2:http://XXXX:8080/invsys";

private Connection dbCon;

public DbConnect1(){}

public boolean connect() throws ClassNotFoundException,SQLException{
try
{
Class.forName(dbDriver);
System.out.println("Loaded the instantDB JDBC driver.");
dbCon = DriverManager.getConnection(dbURL, dbUser, dbPasswd);
System.out.println("Created and connected to database TimingTest");
return true;
}

catch (Throwable e)
{
e.printStackTrace();
System.out.println("FAIL LAHHHHHHHHHHHH");
return false;
}
}

public void close() throws SQLException{
dbCon.close();
}

//accepts the SQL query in the form of a string from the JSP file in which this bean is implemented
public ResultSet execSQL(String sql) throws SQLException{
System.out.println("haha");



//initiates the connection with the dbCon connection object
Statement s = dbCon.createStatement();
ResultSet r = s.executeQuery(sql);
return (r == null) ? null : r;
}

public int updateSQL(String sql) throws SQLException{
Statement s = dbCon.createStatement();
int r = s.executeUpdate(sql);
return (r == 0) ? 0 : r;
}
}

Reply With Quote
  #2  
Old February 29th, 2004, 07:15 PM
Shinto Shinto is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 Shinto User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Here is my JSP file.

<%@ page language='java' %>
<%@ page import="java.sql.*" %>

<jsp:useBean id="DbConnectBean1" scope="page" class="WH.DbConnect1" />
<%
//Get status
/*String message;
String status = request.getParameter("status").trim();

if (status == "duplicateEmail")
message="Please try again. An account with the same emaill address has already been created.";
else if (status == "deleteOk")
message="Delete successful.";
else
message="";*/

//Get Contacts
String name;
String email;
String extNo;
String phoneNo;
String remarks;
String SQLstmt;

SQLstmt = "Select * from CONTACT";
if (DbConnectBean1.connect()==true){

%>
<html>
<head>
<title>Display Contacts</title>
<script src="validation.js" language="Javascript"></script>
<script Language="JavaScript">
//Perform Validation
/* function checkForm() {
var alertString=checkChkBox(theForm.chkItem.value);
formSubmit(alertString);
}*/
</script>
</head>
<body bgcolor="#ffffff">
<form action="USRDelContact.jsp" name="theForm" onsubmit="return checkForm();">
</form>
<table>
<tr>
<td><input type="chkAll" id="chkAll"onclick="checkAll(document.theForm.chkItem)"/></td>
<td>Name</td>
<td>Extension No.</td>
<td>Mobile Phone No.</td>
<td>Email Address</td>
<td>Remarks</td>
<td>&nbsp;</td>
</tr>
<%

ResultSet r = DbConnectBean1.execSQL(SQLstmt);
while (r.next()){
%>
<tr>
<td><input type="checkbox" name="chkItem" id="chkItem" value="<%= r.getString("Email")%>"/></td>
<td><%= r.getString("Emp_Name")%></td>
<td><%= r.getString("Ext_No")%></td>
<td><%= r.getString("Cellphone")%></td>
<td><a href="mailto:<%= r.getString("Email")%>"><%= r.getString("Email")%></a></td>
<td><%= r.getString("Remarks")%></td>
<td><a href="USREditContact.jsp?email=<%= r.getString("Email")%>">Edit</a></td>
</tr>
<%
}

if (r.next()==false)
{
%>
<tr>
<td colspan="7">There are no records currently.</td>
</tr>
<% }
}//end if%>
<tr colspan="6">
<td>
<%//=message%> <input type="submit" name="btnDelete" value="Delete">
</td>
</tr>
</table>
</form>
</body>
</html>

Reply With Quote
  #3  
Old February 29th, 2004, 08:04 PM
kurious's Avatar
kurious kurious is offline
Prom night: 1973
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Dec 2001
Posts: 1,152 kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level)kurious User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Week 2 Days 7 h 36 m 22 sec
Reputation Power: 11
You'll get a better response if you post something more descriptive about what you can't do.

- Is the code compiling? If not, what's the error message?
- Is there a runtime exception? If so, what's the error message?
- Is your page not displaying information? What should it be doing, and what's happening instead?

Also, it's best to try and filter your code down to the essential elements that you're having problems with. The amount that you've posted isn't going to be scanned through by a lot of people.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > JSP with DB2


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway