The integrated development environment adopted by this program is eclipse
The connection database is SQL server2017
The java connection driver of the SQL server used by this program:[Link: https://pan.baidu.com/s/1exEFF0qvSBmvkDP7dt4GMQ Password: a0ic]
When this program uses eclipse to lay out the web project, this driver needs to be arranged inwebcontent——>WEB-INF——>libUnder contents.
The KC table data in our SQL Server database XSCJ is as follows, and then the connection test is performed.
test program:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type"content="text/html;charset=UTF-8">
<title>jsp access to SQL Sever database</title>
</head>
<body>
<%
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection
con=java.sql.DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=XSCJ","sa","//Enter the database login password here));
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from KC");
out.print("<table border=1>");
%>
<table bgcolor="#ffffdd" border="auto" width="auto" >
<%
out.print("<tr>");
out.print("<th>Course ID</th>");
out.print("<th>Course name</th>");
out.print("<th>Teacher name</th>");
out.print("<th>Starting semester</th>");
out.print("<th>Course hours</th>");
out.print("<th>Course Credits</th>");
out.print("</tr>");
while(rs.next()){
out.print("<tr>");
out.print("<td>"+rs.getString(1)+"</td>");
out.print("<td>"+rs.getString(2)+"</td>");
out.print("<td>"+rs.getString(3)+"</td>");
out.print("<td>"+rs.getString(4)+"</td>");
out.print("<td>"+rs.getString(5)+"</td>");
out.print("<td>"+rs.getString(6)+"</td>");
out.print("</tr>");
}
out.print("</table>");
rs.close();
st.close();
con.close();
%>
</body>
</html>
The test results are as follows:
Article Directory 1. Installation of SQL Server and SSMS Second, the connection of SQL Server 1. Installation of SQL Server and SSMS 1. SQL installation download link:SQL Server。 Enter the download ad...
Microsoft's SQL Server database is a good friend for .NET development. The latest version is now 2017. The SQL Server database has its own Management Studio tool, which is basically similar to Visual ...
1. Preparation SQL Server database installation, IDEA and JDK environment installation and configuration. I installed SQL Server 2008, the JAVA environment is as follows, IDEA is installed automatical...
When I first came into contact with using JDBC to connect to a database, I always encountered a lot of problems, making people confused. Therefore, I use SQL Server As an example, explain in detail ho...
Python uses the pymssql module to connect to the SQL server. 1. First install (pip install pymssql) 2. Create a connection object useconnectCreate connection object connect.cursorCreate a cursor ob...
Summary Reference official website:https://docs.microsoft.com/zh-cn/sql/odbc/reference/syntax/sqlallochandle-function?view=sql-server-ver15 Useful blog 1: Useful blog 2: ODBC access to sql server data...
C # Connect to SQL Server Connection connection class Use the SqlConNetion class. When using the SQLConnection class, you want to reference a namespace of system.data.sqlclient. CommandCommand class U...
Use Jmeter to connect to SQL Server database 1. The first step is to download the jar package 2. In the second step, Jmeter adds the jar package path 3. The third step is to add a thread group 4. The ...
table of Contents 1. Database management system 2、MySQL 3、JDBC 4. Database operation 4.1 Query 1. Result set and query: 2. The column name and number of the result set 3. Random query 4. Condition que...
The SQL Server 2008 R2 database and Eclipse are used here; Reference tutorial: start! First find it from the start menuSQL Server Configuration Manager selectNetwork ConfigurationDownxxx agreement, En...