自己写的一个简单的jsp中调用mysql存储过程的查询显示


//创建的存储过程是key123
<%@ page language="java"  pageEncoding="utf-8" %>
<%@ page import="java.sql.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <body>
   
    <%
   try{
   Connection conn;
  CallableStatement stat;
  String url="jdbc:mysql://localhost:3306/mysql";
  String user="root";
  String password="root";
 

  Class.forName("com.mysql.jdbc.Driver");
 
 
  conn=DriverManager.getConnection(url,user,password);

stat=conn.prepareCall("{call key123()}");

ResultSet  result=stat.executeQuery();

while(result.next()){ 

out.println(result.getString("id"));
out.println(result.getString("name"));
}
   }
   catch(Exception e)
    {
  out.println("aaaaaaaaaaaaa");
System.out.println(e);}
  %>

  </body>
</html>

你可能感兴趣的:(java,sql,mysql,jsp,jdbc)