java使用JDBC执行存储过程
附上截图:
附上代码:
public class jdbcprocedure {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
// TODO 自动生成的方法存根
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/jdbc","root","root");
//创建发送SQL的Statement
CallableStatement stat = conn.prepareCall("call sprocedire()");
//执行存储过程
ResultSet rs = stat.executeQuery();
//处理结果集
while(rs.next()) {
System.out.println(rs.getString("Name"));
}
conn.close();
}
}
包什么的就不管了,编译器快捷引入都会的吧