English 中文(简体)
10g 矿石中的多行逆
原标题:Retreival of multiple row from oracle 10g

我在专栏中设立了一个桌子,包括大学名称、学生名称、格鲁诺,并因此属于每个大学和每个学院的专科学校。

现在,我要给学校开课,注明日期,并想到所有学生的姓名,结果和格罗诺,像一个浏览器的结构一样,我写了一页html,用于给学校提供奖状和日期,以及一个小页,用于从数据库中检索不同领域,但没有工作。

页: 1

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org     /TR/html4/loose.dtd">
<html>
 <head>
 <script>
function check()
{
var a=result.college_id.value;
var b=result.date.value;
if(a==""|| b=="")
{
alert("fill the fields")
}
else
{
result.action="result.jsp";
result.method="post";
result.submit();
}
}

 </script>
 </head>

 <body bgcolor="#cc99ff">
 <form name="result">
 <center>
 <table>
 <tr>
 <td>college_id:</td>
 <td><input type="text" name="college_id"></td>
 </tr>
  <tr>
 <td>date:</td>
 <td><input type="text" name="date"></td>
 </tr>
 <tr>
 <td>
 <input type="Button" value="Submit" onClick="check()">
 </td>
 </tr>
 </table>
 </center>
 </body>
 </html>

现在,我是一页,用于检索多个浏览器。

<html>
<body background="main_BG.jpg">
<%@page language="java"%>
<%@page import="java.sql.*,java.util.*"%>
<%!
Connection con;
PreparedStatement ps;
ResultSet rs;
String college_id;
String college_name;
String regno;
String student_name;
String result;
String date;

%>

<%
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","pro","pro
");

college_id=request.getParameter("college_id");
date=request.getParameter("date");


ps=con.prepareStatement("select * from add_result where college_id=? and date=?");
ps.setString(1,college_id);
ps.setString(6,date);
rs=ps.executeQuery();

while(rs.next())
{
college_name=rs.getString(2);
regno=rs.getString(3);
student_name=rs.getString(4);
result=rs.getString(5);
}
else
{
    out.println("no data found");
}
}
catch(Exception e)
{

    out.println("<center><b><font color=lightblue>some error occured...please try  again</font></b></center>");
    out.println("<br><br><a href= result.html ><center><b><font color=lightblue>click here to return..</font></b></center>");

}
%>

<center>
<font color=lightblue>
<b>
Information of student with college_id [<%=college_id%>]:
</b>
</font>
</center>
<p style="position:absolute;left:100;top:100">

<table border="2" width="100%">
<th style="color:yellow">
college_name
</th>
<th style="color:yellow">
regno
</th>
<th style="color:yellow">
student_name
</th>
<th style="color:yellow">
result
</th>
<tr>
<td style="color:lightgreen" align="center"><%=college_name%></td>
<td style="color:lightgreen" align="center"><%=regno%></td>
<td style="color:lightgreen" align="center"><%=student_name%></td>
<td style="color:lightgreen" align="center"><%=result%></td>
</tr>

</table>
</p>
</body>
</html>
问题回答
<%
 try
 {
  Class.forName("oracle.jdbc.driver.OracleDriver");
  con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","pro","pro   ");

  college_id=request.getParameter("college_id");
  date=request.getParameter("date");
  String sql = "select * from add_result where college_id=? and date=?"; 
  ps=con.prepareStatement(sql);
  ps.setString(1,college_id);
  //ps.setString(6,date);
  ps.setString(2,date);
  System.out.println("Sql: " + sql);
  rs=ps.executeQuery();
  // process resultset below
 }
 catch(Exception e)
 {

   out.println("<center><b><font color=lightblue>some error occured...please try again</font></b></center>"); 
   out.println("<br><br><a href= result.html ><center><b><font color=lightblue>click here to return..</font></b></center>");

  }
%>

<center>
<font color=lightblue>
<b>
Information of student with college_id [<%=college_id%>]:
</b>
</font>
</center>
<p style="position:absolute;left:100;top:100">

<table border="2" width="100%">
<th style="color:yellow">
college_name
</th>
<th style="color:yellow">
regno
</th>
<th style="color:yellow">
student_name
</th>
<th style="color:yellow">
result
</th>
<%
 if(rs!=null){
  while(rs.next())
  {
   college_name=rs.getString(2);
   regno=rs.getString(3);
   student_name=rs.getString(4);
   result=rs.getString(5);
%>
 <tr>
  <td style="color:lightgreen" align="center"><%=college_name%></td>
  <td style="color:lightgreen" align="center"><%=regno%></td>
  <td style="color:lightgreen" align="center"><%=student_name%></td>
  <td style="color:lightgreen" align="center"><%=result%></td>
 </tr>
<%
  } // result set loop ends here
 }else{
%>
  <tr>
   <td colspan="4" style="color:red" align="center">No Data Found</td>
   </tr>
<%
 }  //if condition ends here
%>




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签