Home > Back-end >  Consult bosses
Consult bosses

Time:09-17

, I want to ask how to solve the problem.
<% @ page language="Java" import="Java. Util. *, Java, SQL *" pageEncoding="utf-8" % & gt;


<body>
<%
String username="";
String password="";
The username=request. The getParameter (" username ");
Password=request. The getParameter (" password ");

String driverName="com. Microsoft. Essentially. JDBC. SQLServerDriver";
String dbURL="JDBC: essentially://localhost: 1433; DatabaseName=Login ";
String userName="root";
String userPwd="sa";
String SQL="select the Username from the users where the Username='" + Username +"' ";
String sql1="select the Password from the users where the Password='" +" + "' ";
The Connection STMT=DriverManager. GetConnection (dbURL, userName, userPwd);
Class.forname (driverName);
The Statement stmt1=STMT. CreateStatement ();
The Statement stmt2=STMT. CreateStatement ();
The ResultSet rs=stmt1. ExecuteQuery (SQL);
The ResultSet rs1=stmt2. ExecuteQuery (sql1);
If (rs), next () & amp; & Rs1. Next ())
{
Request. GetRequestDispatcher (" suc. JSP "). The forward (request, response);
} else {
Request. GetRequestDispatcher (" fail. JSP "). The forward (request, response);
}
% & gt;

CodePudding user response:

The Connection STMT=DriverManager. GetConnection (dbURL, userName, userPwd); Say the problem is wrong, I don't know how to change

CodePudding user response:

Class.forname (driverName); On top of the drive link,

CodePudding user response:

Calls to drive, and then connect to the database, and then create SQL statements, to perform for the return value, close the connection, then the return value to judge turned

CodePudding user response:

The
refer to the original poster weixin_48436316 response:
, I want to ask how to solve this problem!
<% @ page language="Java" import="Java. Util. *, Java, SQL *" pageEncoding="utf-8" % & gt;


<body>
<%
String username="";
String password="";
The username=request. The getParameter (" username ");
Password=request. The getParameter (" password ");

String driverName="com. Microsoft. Essentially. JDBC. SQLServerDriver";
String dbURL="JDBC: essentially://localhost: 1433; DatabaseName=Login ";
String userName="root";
String userPwd="sa";
String SQL="select the Username from the users where the Username='" + Username +"' ";
String sql1="select the Password from the users where the Password='" +" + "' ";
The Connection STMT=DriverManager. GetConnection (dbURL, userName, userPwd);
Class.forname (driverName);
The Statement stmt1=STMT. CreateStatement ();
The Statement stmt2=STMT. CreateStatement ();
The ResultSet rs=stmt1. ExecuteQuery (SQL);
The ResultSet rs1=stmt2. ExecuteQuery (sql1);
If (rs), next () & amp; & Rs1. Next ())
{
Request. GetRequestDispatcher (" suc. JSP "). The forward (request, response);
} else {
Request. GetRequestDispatcher (" fail. JSP "). The forward (request, response);
}
% & gt;



No import driver package
  • Related