jsp执行mysql带参数的存储过程<%@ page contentType="text/html; charset=gb2312" %>
jsp执行mysql带参数的存储过程
<%@ page language="java" %>
jsp执行mysql带参数的存储过程
<%@ page import="com.mysql.jdbc.Driver" %>
jsp执行mysql带参数的存储过程
<%@ page import="java.sql.*" %>
jsp执行mysql带参数的存储过程
<%
jsp执行mysql带参数的存储过程
//驱动程序名
jsp执行mysql带参数的存储过程
String driverName="com.mysql.jdbc.Driver";
jsp执行mysql带参数的存储过程
//数据库用户名
jsp执行mysql带参数的存储过程
String userName="root";
jsp执行mysql带参数的存储过程
//密码
jsp执行mysql带参数的存储过程
String userPasswd="123";
jsp执行mysql带参数的存储过程
//数据库名
jsp执行mysql带参数的存储过程
String dbName="stock";
jsp执行mysql带参数的存储过程
//表名
jsp执行mysql带参数的存储过程
String tableName="users";
jsp执行mysql带参数的存储过程
//联结字符串
jsp执行mysql带参数的存储过程
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
jsp执行mysql带参数的存储过程Class.forName(
"com.mysql.jdbc.Driver").newInstance();
jsp执行mysql带参数的存储过程Connection conn
=DriverManager.getConnection(url);
jsp执行mysql带参数的存储过程String WhereCondition
="age<=30";
jsp执行mysql带参数的存储过程String OrderByExpress
="id Desc";
jsp执行mysql带参数的存储过程
//调用存储过程的方法,并且传递了参数,不传参数就 call GetUsersDynamic可以了
jsp执行mysql带参数的存储过程
CallableStatement cstmt=conn.prepareCall("{call GetUsersDynamic(?,?)}");
jsp执行mysql带参数的存储过程cstmt.setString(
1,WhereCondition);
jsp执行mysql带参数的存储过程cstmt.setString(
2,OrderByExpress);
jsp执行mysql带参数的存储过程ResultSet rs 
= cstmt.executeQuery(); 
jsp执行mysql带参数的存储过程
jsp执行mysql带参数的存储过程
//获得数据结果集合
jsp执行mysql带参数的存储过程
ResultSetMetaData rsmd = rs.getMetaData();
jsp执行mysql带参数的存储过程
//确定数据集的列数,亦字段数
jsp执行mysql带参数的存储过程
int numColumns=rsmd.getColumnCount();
jsp执行mysql带参数的存储过程
// 输出每一个列名
jsp执行mysql带参数的存储过程
out.print("<table border=1><tr>");
jsp执行mysql带参数的存储过程
for(int i=1;i<=numColumns;i++)//注意下标从1开始的 

相关文章: