日期:2014-05-17 浏览次数:20659 次
<%@ page language="java" contentType="text/html; charset=gb2312" pageEncoding="gb2312"%> <%@ page import="java.sql.Connection"%> <%@ page import="java.sql.DriverManager"%> <%@ page import="java.sql.Statement"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>执行打印记录的信息</title> </head> <% //获取当前页编号ID的值 String ID = (String) request.getParameter("ID"); String dllname= (String) request.getParameter("dllname"); //定义您的驱动器及数据库的URL、用户名和密码 String driverName = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; String url = "jdbc:sqlserver://192.168.0.2:1433;databaseName=klrq"; String username = "SA"; String password = "GUOOUG"; Connection con = null; try { // 创建数据库连接 Class.forName(driverName); con = DriverManager.getConnection(url, username, password); // 创建数据库执行语句 Statement sqlstatement = con.createStatement(); // 将对应编号ID是否打印字段改为true sqlstatement .execute("exec yu @id='" + ID + "', @dllname='"+ dllname + "'"); con.close(); } catch (Exception e) { e.printStackTrace(); } %> <body> </body> </html>