Advertisement
Advertisement
| 03.03.2008 at 08:11PM PST, ID: 23211660 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
|
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: |
<%@ page import="java.sql.*" %>
<HTML>
<HEAD> <TITLE> The JDBCQuery JSP </TITLE> </HEAD>
<BODY BGCOLOR=white>
<%
connStr = "jdbc:oracle:thin:@<host>:1521:<SID>";
%>
<% String searchCondition = request.getParameter("cond");
if (searchCondition != null) { %>
<H3> Search results for : <I> <%= searchCondition %> </I> </H3>
<%= runQuery(connStr,searchCondition) %>
<HR><BR>
<% } %>
<B>Enter a search condition:</B>
<FORM METHOD=get>
<INPUT TYPE="text" NAME="cond" SIZE=30>
<INPUT TYPE="submit" VALUE="Enter Billing Code");
</FORM>
</BODY>
</HTML>
<%!
private String runQuery(String connStr, String cond) throws SQLException {
Connection conn = null;
Statement stmt = null;
ResultSet rset = null;
try {
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
conn = DriverManager.getConnection(connStr,
"<user>", "<pwd>");
stmt = conn.createStatement();
rset = stmt.executeQuery ("SELECT DESCRIPTION, ITEM_CODE, INCOME_ACCOUNT FROM BILLING_CODE_VW "+
(cond.equals("") ? "" : "WHERE " + cond ));
return (formatResult(rset));
} catch (SQLException e) {
return ("<P> SQL error: <PRE> " + e + " </PRE> </P>\n");
} finally {
if (rset!= null) rset.close();
if (stmt!= null) stmt.close();
if (conn!= null) conn.close();
}
}
private String formatResult(ResultSet rset) throws SQLException {
StringBuffer sb = new StringBuffer();
if (!rset.next())
sb.append("<P> No matching rows.<P>\n");
else { sb.append("<table border=\"1\" cellpadding=\"5\"><B><tr><th>Description</th><th>Item Code</th><th>Income Account</th></tr>");
do { sb.append("<td>" + rset.getString(1) +
"<td>" + rset.getString(2) +
"<td>" + rset.getString(3) +
"</tr>\n");
} while (rset.next());
sb.append("</B></TABLE>");
}
return sb.toString();
}
%>
|