zoukankan      html  css  js  c++  java
  • 软件工程概论第一篇—实现简单 的连接数据库

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

    Insert title here

    用户:
    密码:

    <%@ page language="java" import="java.sql.*" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

    Insert title here <% String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver"; String dbURL="jdbc:sqlserver://localhost:1433;DatabaseName = test"; String userName="sa"; String userPwd="123456"; Class.forName(driverName); Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd); String sql = "select * from Table_1 where [用户名]=? and [密码]=?"; PreparedStatement pstmt = dbConn.prepareStatement(sql); request.setCharacterEncoding("UTF-8"); String user = request.getParameter("username"); String pass = request.getParameter("pass"); pstmt.setString(1, user); pstmt.setString(2, pass); ResultSet rs = pstmt.executeQuery(); if(rs.next()) { %>

    登陆成功!

    <% } else { %>

    登陆失败!

    <% } %>

  • 相关阅读:
    作业3
    字符串的应用
    java类与对象
    作业
    水仙花数
    java例
    读书笔记(构建之法-11.19)
    补psp进度(11月4号-9号)
    PSP进度(11~16)
    团队项目-约跑软件需求规格说明书
  • 原文地址:https://www.cnblogs.com/jiandanqinxin/p/6445957.html
Copyright © 2011-2022 走看看