C
coobo
Unregistered / Unconfirmed
GUEST, unregistred user!
========================.java
package selectchart;
import java.sql.*;
public class beanSQL {
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbcdbc:sunshine";
Connection conn = null;
ResultSet rs = null;
public void beanSQL() {
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("beanSQL(): " + e.getMessage());
}
}
public ResultSet mySelect(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
public void myUpdate(String sql) {
try {
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}
===========================.jsp
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" import="java.sql.*" %>
<%@ page import="java.sql.*"%>
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="java.lang.*"%>
<%@ page session="true"%>
<jsp:useBean id="recordSelect" scope="page" class="selectchart.beanSQL" />
<jsp:setProperty name="recordSelect" property="*" />
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<title>Untitleddo
cument</title>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
</head>
<script>
function AddField(Title,Value,TargetList) {
var objSelected = new Option(Title, Value);
TargetList.options[TargetList.length] = objSelected;
// TargetList.options[TargetList.lengg.-1].selected = true;
}
function pageload(){
<%
try{
String tablename;
String tableshow;
String sqlstr="SELECT * FROM tablelist";
ResultSet rsTableName = recordSelect.mySelect(sqlstr);
while (rsTableName.next()) {
tablename = rsTableName.getString("tablename");
tableshow = rsTableName.getString("tableshow");
%>
//AddField("aaa","aaa",document.forms.frmTableName.lstTableName);
AddField("<%=tableshow%>","<%=tablename%>",document.forms.frmTableName.lstTableName);
<% }
rsTableName.close();
}
catch(Exception ex) {} %>
}
function tablechange(){
<% session.putValue("cansave","no");%>
frmTableName.submit();
}
</script>
<body bgcolor="#FFFFFF" onLoad="pageload();">
<table width="86%" border="1" height="39" align="left" cellspacing="0" bordercolorlight="#FFFFFF">
<form name="frmTableName" action="chartbottom.jsp" target="chartbottom" method="POST">
<tr>
<td width="26%" height="29">数据库名称</td>
<td width="74%" height="29">
<select name="lstDatabaseName" size="1" onChange="javascript: parent.charttopright.location.reload();">
<option value="数据库1">数据库1</option>
<option value="数据库2">数据库2</option>
<option value="数据库3">数据库3</option>
<option value="数据库4">数据库4</option>
</select>
</td>
</tr>
<tr>
<td width="26%" height="21">数据表名称</td>
<td width="74%" height="21">
<select name="lstTableName" size="1" onChange="tablechange()">
</select>
</td>
</tr>
</form>
</table>
</body>
</html>
package selectchart;
import java.sql.*;
public class beanSQL {
String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbcdbc:sunshine";
Connection conn = null;
ResultSet rs = null;
public void beanSQL() {
try {
Class.forName(sDBDriver);
}
catch(java.lang.ClassNotFoundException e) {
System.err.println("beanSQL(): " + e.getMessage());
}
}
public ResultSet mySelect(String sql) {
rs = null;
try {
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
return rs;
}
public void myUpdate(String sql) {
try {
conn = DriverManager.getConnection(sConnStr);
Statement stmt = conn.createStatement();
stmt.executeUpdate(sql);
}
catch(SQLException ex) {
System.err.println("aq.executeQuery: " + ex.getMessage());
}
}
===========================.jsp
<%@ page contentType="text/html;charset=gb2312" %>
<%@ page language="java" import="java.sql.*" %>
<%@ page import="java.sql.*"%>
<%@ page info="database handler"%>
<%@ page import="java.io.*"%>
<%@ page import="java.util.*"%>
<%@ page import="javax.servlet.*"%>
<%@ page import="javax.servlet.http.*"%>
<%@ page import="java.lang.*"%>
<%@ page session="true"%>
<jsp:useBean id="recordSelect" scope="page" class="selectchart.beanSQL" />
<jsp:setProperty name="recordSelect" property="*" />
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css">
<title>Untitleddo
cument</title>
<meta http-equiv="Content-Type" content="text/html;
charset=gb2312">
</head>
<script>
function AddField(Title,Value,TargetList) {
var objSelected = new Option(Title, Value);
TargetList.options[TargetList.length] = objSelected;
// TargetList.options[TargetList.lengg.-1].selected = true;
}
function pageload(){
<%
try{
String tablename;
String tableshow;
String sqlstr="SELECT * FROM tablelist";
ResultSet rsTableName = recordSelect.mySelect(sqlstr);
while (rsTableName.next()) {
tablename = rsTableName.getString("tablename");
tableshow = rsTableName.getString("tableshow");
%>
//AddField("aaa","aaa",document.forms.frmTableName.lstTableName);
AddField("<%=tableshow%>","<%=tablename%>",document.forms.frmTableName.lstTableName);
<% }
rsTableName.close();
}
catch(Exception ex) {} %>
}
function tablechange(){
<% session.putValue("cansave","no");%>
frmTableName.submit();
}
</script>
<body bgcolor="#FFFFFF" onLoad="pageload();">
<table width="86%" border="1" height="39" align="left" cellspacing="0" bordercolorlight="#FFFFFF">
<form name="frmTableName" action="chartbottom.jsp" target="chartbottom" method="POST">
<tr>
<td width="26%" height="29">数据库名称</td>
<td width="74%" height="29">
<select name="lstDatabaseName" size="1" onChange="javascript: parent.charttopright.location.reload();">
<option value="数据库1">数据库1</option>
<option value="数据库2">数据库2</option>
<option value="数据库3">数据库3</option>
<option value="数据库4">数据库4</option>
</select>
</td>
</tr>
<tr>
<td width="26%" height="21">数据表名称</td>
<td width="74%" height="21">
<select name="lstTableName" size="1" onChange="tablechange()">
</select>
</td>
</tr>
</form>
</table>
</body>
</html>