clonmelog
asked on
Query returning null data
Hi,
I have a form which is performing a user search by employee name (emp_name) from a form. the page is returning without an error with no results even when i hard code in the employee name to the query.
the code is:
<%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<br>
<br><head>
<title>Momentum Marketing Intranet</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="file:///C|/Documents %20and%20S ettings/01 445693.AG0 5PC14/Desk top/moment um/text.cs s" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {font-size: 14px}
.style2 {
font-family: "Times New Roman", Times, serif;
font-size: 16px;
}
-->
</style></head>
<%
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.OracleDriver" ;
Class.forName(driverName);
// Create a connection to the database
String serverName = "witnt07.wit.ie";
String portNumber = "1521";
String sid = "orawit";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "W01445693";
String password = "EPDEXZ";
connection = DriverManager.getConnectio n(url, username, password);
} catch (ClassNotFoundException e) {
out.println( "Could not find the database driver");
} catch (SQLException e) {
e.printStackTrace();
out.println( "Could not connect to the database");
}
%><body bgcolor="#FFFFFF">
<table width="770" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
<tr>
<td bgcolor="#FFFFFF">
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><a href="file:///C|/Documents %20and%20S ettings/01 445693.AG0 5PC14/Desk top/moment um/adminop tions.jsp" ><img src="file:///C|/Documents% 20and%20Se ttings/014 45693.AG05 PC14/Deskt op/momentu m/mom_logo .gif" width="256" height="74" border="0"></a></td>
<td width="411"> </td>
</tr>
<tr>
<td width="359"><img src="file:///C|/Documents% 20and%20Se ttings/014 45693.AG05 PC14/Deskt op/momentu m/leftbar. gif" width="359" height="39"></td>
<td align="right" bgcolor="336CA1"> </t d>
</tr>
<tr>
<td colspan="2"><img src="file:///C|/Documents% 20and%20Se ttings/014 45693.AG05 PC14/Deskt op/momentu m/topbar.g if" width="770" height="69"></td>
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="file:///C|/Doc uments%20a nd%20Setti ngs/014456 93.AG05PC1 4/Desktop/ momentum/b ut_bg.gif" >
<tr>
<td align="right"><img src="file:///C|/Documents% 20and%20Se ttings/014 45693.AG05 PC14/Deskt op/momentu m/spacer.g if" width="15" height="23"><img src="file:///C|/Documents% 20and%20Se ttings/014 45693.AG05 PC14/Deskt op/momentu m/spacer.g if" width="15" height="23"><img src="file:///C|/Documents% 20and%20Se ttings/014 45693.AG05 PC14/Deskt op/momentu m/spacer.g if" width="15" height="23"><img src="file:///C|/Documents% 20and%20Se ttings/014 45693.AG05 PC14/Deskt op/momentu m/spacer.g if" width="15" height="23"><img src="file:///C|/Documents% 20and%20Se ttings/014 45693.AG05 PC14/Deskt op/momentu m/spacer.g if" width="15" height="23"><img src="file:///C|/Documents% 20and%20Se ttings/014 45693.AG05 PC14/Deskt op/momentu m/spacer.g if" width="45" height="23"></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="167" rowspan="3" valign="top" bgcolor="8FBEE8"> </td>
<td colspan="2" align="center">
<table width="95%" border="0" cellpadding="5" cellspacing="0" class="text">
<tr>
<td class="text">
<p><font color="#000000"><span class="style1"><br>
<%
String user = request.getParameter("empl oyee");
// Create a result set containing all data from my_table
Statement stmt = connection.createStatement ();
ResultSet rs = stmt.executeQuery("SELECT * FROM Employees where Emp_Name = '" + user + "'");
%>
<%while (rs.next ()){%>
</span></font><font color="#000000"><br>
</font></p>
<table width="100%" border="0">
<tr>
<td width="24%"><b>Employee ID:</b></td>
<td width="76%"><%=rs.getStrin g("Emp_ID" )%> </td>
</tr>
<tr>
<td width="24%"><b>Employee Name:</b></td>
<td width="76%"><%=rs.getStrin g("Emp_Nam e")%></td>
</tr>
<tr>
<td width="24%"><b>Employee DOB:</b></td>
<td width="76%"><%= new java.text.SimpleDateFormat ("dd/MMM/y y").format (rs.getDat e("Emp_DOB "))%></td>
</tr>
<tr>
<td width="24%"><b>Employee Address:</b></td>
<td width="76%"><%=rs.getStrin g("Emp_Add ress")%></ td>
</tr>
<tr>
<td width="24%"><b>Employee Phone:</b></td>
<td width="76%"><%=rs.getStrin g("Emp_Pho ne")%></td >
</tr>
<tr>
<td width="24%"><b>Employee Email:</b></td>
<td width="76%"><%=rs.getStrin g("Emp_Ema il")%></td >
</tr>
<tr>
<td width="24%"><b>Employee Project:</b></td>
<td width="76%"><%=rs.getStrin g("Emp_Pro ject")%></ td>
</tr>
<tr>
<td width="24%"><b>Employee Start:</b></td>
<td width="76%"><%= new java.text.SimpleDateFormat ("dd/MMM/y y").format (rs.getDat e("Emp_Sta rtDate"))% ></td>
</tr>
<tr>
<td width="24%"><b>Employee Bank No:</b></td>
<td width="76%"><%=rs.getStrin g("Emp_Ban kDetails") %></td>
</tr>
</table>
<p><font color="#000000"><a href="file:///C|/Documents %20and%20S ettings/01 445693.AG0 5PC14/Desk top/moment um/adminop tions.jsp" >Return to
Admin Options</a></font></p>
</td>
</tr>
</table>
<%}%>
<%
connection.close();
%>
</td>
</tr>
<tr>
<td colspan="2" valign="bottom">
<table width="82%" border="0" cellspacing="0" cellpadding="8">
<tr>
<td align="center" valign="bottom"><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">©
2005 Momentum Marketing Services Ltd.</font></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Im getting a connection to the db fine so im not sure why theres no data printed to the screen :(
I have a form which is performing a user search by employee name (emp_name) from a form. the page is returning without an error with no results even when i hard code in the employee name to the query.
the code is:
<%@ page import="java.sql.*" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<br>
<br><head>
<title>Momentum Marketing Intranet</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="file:///C|/Documents
<style type="text/css">
<!--
.style1 {font-size: 14px}
.style2 {
font-family: "Times New Roman", Times, serif;
font-size: 16px;
}
-->
</style></head>
<%
Connection connection = null;
try {
// Load the JDBC driver
String driverName = "oracle.jdbc.OracleDriver"
Class.forName(driverName);
// Create a connection to the database
String serverName = "witnt07.wit.ie";
String portNumber = "1521";
String sid = "orawit";
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
String username = "W01445693";
String password = "EPDEXZ";
connection = DriverManager.getConnectio
} catch (ClassNotFoundException e) {
out.println( "Could not find the database driver");
} catch (SQLException e) {
e.printStackTrace();
out.println( "Could not connect to the database");
}
%><body bgcolor="#FFFFFF">
<table width="770" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#000000">
<tr>
<td bgcolor="#FFFFFF">
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><a href="file:///C|/Documents
<td width="411"> </td>
</tr>
<tr>
<td width="359"><img src="file:///C|/Documents%
<td align="right" bgcolor="336CA1"> </t
</tr>
<tr>
<td colspan="2"><img src="file:///C|/Documents%
</tr>
<tr>
<td colspan="2">
<table width="100%" border="0" cellspacing="0" cellpadding="0" background="file:///C|/Doc
<tr>
<td align="right"><img src="file:///C|/Documents%
</tr>
</table>
</td>
</tr>
</table>
<table width="770" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="167" rowspan="3" valign="top" bgcolor="8FBEE8"> </td>
<td colspan="2" align="center">
<table width="95%" border="0" cellpadding="5" cellspacing="0" class="text">
<tr>
<td class="text">
<p><font color="#000000"><span class="style1"><br>
<%
String user = request.getParameter("empl
// Create a result set containing all data from my_table
Statement stmt = connection.createStatement
ResultSet rs = stmt.executeQuery("SELECT * FROM Employees where Emp_Name = '" + user + "'");
%>
<%while (rs.next ()){%>
</span></font><font color="#000000"><br>
</font></p>
<table width="100%" border="0">
<tr>
<td width="24%"><b>Employee ID:</b></td>
<td width="76%"><%=rs.getStrin
</tr>
<tr>
<td width="24%"><b>Employee Name:</b></td>
<td width="76%"><%=rs.getStrin
</tr>
<tr>
<td width="24%"><b>Employee DOB:</b></td>
<td width="76%"><%= new java.text.SimpleDateFormat
</tr>
<tr>
<td width="24%"><b>Employee Address:</b></td>
<td width="76%"><%=rs.getStrin
</tr>
<tr>
<td width="24%"><b>Employee Phone:</b></td>
<td width="76%"><%=rs.getStrin
</tr>
<tr>
<td width="24%"><b>Employee Email:</b></td>
<td width="76%"><%=rs.getStrin
</tr>
<tr>
<td width="24%"><b>Employee Project:</b></td>
<td width="76%"><%=rs.getStrin
</tr>
<tr>
<td width="24%"><b>Employee Start:</b></td>
<td width="76%"><%= new java.text.SimpleDateFormat
</tr>
<tr>
<td width="24%"><b>Employee Bank No:</b></td>
<td width="76%"><%=rs.getStrin
</tr>
</table>
<p><font color="#000000"><a href="file:///C|/Documents
Admin Options</a></font></p>
</td>
</tr>
</table>
<%}%>
<%
connection.close();
%>
</td>
</tr>
<tr>
<td colspan="2" valign="bottom">
<table width="82%" border="0" cellspacing="0" cellpadding="8">
<tr>
<td align="center" valign="bottom"><font color="#000000" size="1" face="Verdana, Arial, Helvetica, sans-serif">©
2005 Momentum Marketing Services Ltd.</font></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Im getting a connection to the db fine so im not sure why theres no data printed to the screen :(
ASKER
Yes, that was the firts thing that i checked!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SELECT * FROM Employees where Emp_Name = 'aUser'
returns any data. Can you check this?