给你个简单的Javascript例子。仔细看看啊!
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<%@ page import="java.sql.*" %>
<%
Connection conn=null;
Statement stmt=null;
ResultSet rs=null,rs1=null,rs2=null;
String sql;
int count;
int count2;
String drivername="com.mysql.jdbc.Driver";
String url="jdbc:mysql://localhost/selectbiao";
try{
Class.forName(drivername);
conn=DriverManager.getConnection(url,"root","root");
stmt=conn.createStatement();
sql="select * from city order by locationid asc";
rs=stmt.executeQuery(sql);
}catch(SQLException e){
System.out.println(e.getMessage());
}
%>
<%
sql="select * from village order by districtid asc";
rs2=stmt.executeQuery(sql);
%>