Home > News list > Programming/Database >> Database Operation Tutorial

Idea Connect SQL Sever2019 Tutorial (Super Detailed)

Database Operation Tutorial 2023-05-12 12:11:42 Source: Network

catalogue1. First, let's open sqlsevers2

Configured for many days and reported an error… I really wrote this article with tears in my eyes

1. First, let's open sqlsevers

2. Open the SQL Configuration Manager

Set the TCP ports of IP1, IP10, and IPALL to 1433, and the IP address to 127.0.0.1. After setting up, be sure torestartThe sqlseaver service is shown in the following figure:

3. Enable Telnet service

Open the control panel and click&quo; Program”, Click on&quo; Enable or disable Windows features&# quo;, Open the Telnet service.

Check if the connection is successful, and if successful, the following situation will appear:

4. Go to the official website to download jdbc that is compatible with local jdk

https://docs.microsoft.com/zh-cn/sql/connect/jdbc/microsoft-jdbc-driver-for-sql-server-support-matrix?view=sql -server-2017#java-and-jdbc-specification-support

5. Configure idea

Click on"+& ldquo; Click on" Java” Add the downloaded jre path. (JRE must be compatible with the JDK version, otherwise an error will be reported. This is why I have been poorly configured.)

6. Test whether the connection is successful

importjava.sql.Connection; importjava.sql.DriverManager; importjava.sql.*; publicclassTest{privatestaticConnectiondbConn=null;publicstaticvoidmain(String[]args){StringdbURL="jdbc: sqlserver://localhost:1433 ; DatabaseName=Stu ";//Enter your own database name here (i.e., change Stu to your own database name). You can try {//1. Load driver Class. forName (" com. microsoft. sqlserver. jdbc. SQLServerDriver "); System. out. println (" Successfully loaded driver! ");//2. Connect to dbConn=DriverManager. getConnection (dbURL," sa "," 123 ");//The password here is changed to the password you modified in the first step, and the username is usually" Sa "System. out. println()" Successfully connected to database! "; StringSQL=" selectsnamefrom student ";//This statement is the query statement for the table. Modify the name PreparedStatementstatement=null; statement=dbConn. prepareStatement (SQL); ResultSetres=null; res=statement. executeQuery(); while (res. text()) {Stringtitle=res. getString (" sname "); System. out. println (title);} catch (Exception ione) {e.printStackTrace() ; System. out. println ("Connection to database failed!"); {}}

You can see here that I successfully connected

This is an article about connecting to SQL through idea; That's all for the article on Sever2019 [really detailed], more related ideas connecting to SQL  Please search for previous articles of Script Home or continue browsing related articles below. We hope everyone can support Script Home more in the future!

Tag: Idea Connect SQL Sever2019 Tutorial Super Detailed


Disclaimer: The content of this article is sourced from the internet. The copyright of the text, images, and other materials belongs to the original author. The platform reprints the materials for the purpose of conveying more information. The content of the article is for reference and learning only, and should not be used for commercial purposes. If it infringes on your legitimate rights and interests, please contact us promptly and we will handle it as soon as possible! We respect copyright and are committed to protecting it. Thank you for sharing.

AdminSo

http://www.adminso.com

Copyright @ 2007~2024 All Rights Reserved.

Powered By AdminSo

Open your phone and scan the QR code on it to open the mobile version


Scan WeChat QR code

Follow us for more hot news

AdminSo Technical Support