关于JAVA从ORACLE里取出数据怎么放入LIST里?
<%@ page language="java" import="java.sql.*,java.util.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//1.加载驱动
Class.forName("oracle.jdbc.driver.OracleDriver");
//2.找开连接
String OracleURL = "jdbc:oracle:thin:@192.168.4.202:1521:ujpcn";
Connection conn=DriverManager.getConnection(OracleURL,"netcool","netcool");
//xxxx这里是数据库的用户名,****这里是数据库的密码。
//3.创建statement
Statement stat=conn.createStatement();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href=" <%=basePath%>">
<title>My JSP 'MyJsp.jsp' starting page </title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<div align="center">"自由短信发送页面 </div>
<form id="form1" name="form1" method="post" action="">
<label>
<div align="center">短信内容编写栏:
(每条短信可含60个字符,超出将被拆分)
<input type="submit" name="Submit7" value="发送短信" />
<input type="submit" name="Submit" value="退出" />
</div>
</label>
<label> </label>
<label>
<div align="center">
<textarea name="textarea3" cols="60" rows="8"> </textarea>
<br />
<div align="center"> <br />
</div>
</div>
</label>
</form>
<div align="center">
<table width="545" height="22" border="0">
<tr>
<td width="225"> <div align="center">可选收件人列表 </div> </td>
<td width="77"> </td>
<td width="229"> <div align="center">已选收件人列表 </div> </td>
</tr>
</table>
<table width="410" border="0" height="330">
<tr>
<td valign="top"> <br> </td> <td width="227" rowspan="6">
<select id="s1" onpropertychange="javascript:checkButtonStatus();" multiple style="WIDTH: 147px; HEIGHT: 200px">
<%
//4.执行SQL
ResultSet rs=stat.executeQuery("select ChooseAddressee from ChooseAddressee");
//最后再把rs里面的值循环取出来
while(rs.next())
{ //rs.getInt();
} rs.close(); %>
<option value=""></option>
<option value=""></option>
<OPTION value=""></OPTION>
<OPTION value=""></OPTION>
<OPTION value=""></OPTION>
</select> </td>
<td width="74"> </td>
<td width="227" rowspan="6">
<select id="s2" multiple style="WIDTH: 147px; HEIGHT: 200px" onpropertychange="javascript:checkButtonStatus();" >
</select>
</td>
</tr>
<tr>
<td valign="top"> <br> </td> <td> <form id="form5" name="form5" method="post" action="">
<label> </label>
<div align="center">
<INPUT class="btn2" id="btnAllLeft" onclick="transferItem(-2);" type="button" value="< <" name="btnAllLeft2">
</div>
</form> </td>
</tr>
<tr>
<td valign="top"> <br> </td> <td> <div align="center">
<form id="form6" name="form6" method="post" action="">
<label>
<INPUT class="btn2" id="btnAllRight" onclick="transferItem(2);" type="button" value="> >" name="btnAllRight">
</label>
</form>
</div> </td>
</tr>
<tr>
<td valign="top"> <br> </td> <td> <div align="center">
<form id="form7" name="form7" method="post" action="">
<label>
<INPUT class="btn2" id="btnLeft" onclick="transferItem(-1);" type="button" value=" < " name="btnLeft2">
</label>
</form>
</div> </td>
</tr>
<tr>
<td valign="top"> <br> </td> <td> <form id="form8" name="form8" method="post" action="">
<label> </label>
<div align="center">
<INPUT class="btn2" id="btnRight" onclick="transferItem(1);" type="button" value=" > " name="btnRight2">
</div>
</form> </td>
</tr>
<tr>
<td valign="top"> <br> </td> <td> </td>
</tr>
</table>
</div>
<form action="" method="post" enctype="multipart/form-data" name="form9" id="form9">
<lable>
<div align="center">导入收信人联系方式
<input name="file" type="file" size="40" />
<input type="submit" name="Submit6" value="导入" />
</div>
</lable>
</form>
</body>
</html>
<SCRIPT LANGUAGE=javascript>
<!--
function transferItem(iDirect)
{
var oListLeft = document.all.s1;
var oListRight = document.all.s2;
if(iDirect <0) {
oListLeft =document.all.s2;
oListRight =document.all.s1;
}
iDirect = iDirect>0?iDirect:-1*iDirect;
for (var i=0;i <oListLeft.options.length;i++)
{ if ((iDirect ==1 && oListLeft.options[i].selected )|| iDirect ==2 )
{ var oldOp = oListLeft.options[i];
var newOp =
new Option(oldOp.text,oldOp.value);
oListRight.options.add(newOp); oListLeft.options[i] = null; i--; } }
checkButtonStatus();
}
function checkButtonStatus()
{ var oListLeft = document.all.s1;
var oListRight = document.all.s2;
var btn1 = document.all.btnLeft;
var btn2 = document.all.btnRight;
var btn3 = document.all.btnAllLeft;
var btn4 = document.all.btnAllRight;
// alert(bHaveCheckedOne(oListLeft));
btn1.disabled =!bHaveCheckedOne(oListRight);
btn2.disabled =!bHaveCheckedOne(oListLeft);
btn3.disabled =oListRight.options.length <=0;
btn4.disabled =oListLeft.options.length <=0; }
function bHaveCheckedOne(obj)
{ for(var i=0;i <obj.options.length;i++)
{ if(obj.options[i].selected)
{ return true; }
} return false;
} //-->
</SCRIPT>
红字部分。。我知道rs里有5个值我怎么一一赋进去?
[解决办法]
<select id="s1" onpropertychange="javascript:checkButtonStatus();" multiple style="WIDTH: 147px; HEIGHT: 200px">
rs=stat.executeQuery("select ChooseAddressee from ChooseAddressee");
//最后再把rs里面的值循环取出来
while(rs.next()) {
<option value="rs.getInt("字段名")">rs.getString("字段名")</option>
}
</select>
如果直接传字符串,保持两个字段名一致即可。例如:
<option value="rs.getString("字段名")">rs.getString("字段名")</option>