当前位置:网站首页>Eclipse connects to SQL server database "recommended collection"
Eclipse connects to SQL server database "recommended collection"
2022-07-30 14:10:00 【Full stack programmer webmaster】
大家好,又见面了,我是你们的朋友全栈君.
1.准备,下载JDBC驱动程序
To be able to use the database must have a correspondingJDBC驱动程序,然后到Microsoft官网下载https://www.microsoft.com/zh-cn/download/details.aspx?id=11774
下载完成之后
After decompression with decompression tool
Click on that folder and enter
2.配置SQL sever是否可以sa登录,If not, refer to the link below
http://jingyan.baidu.com/article/8cdccae9452b3c315513cd52.html
设置好之后,然后在“我的电脑”右击选择“管理” 接着点击“服务和应用程序”,选择“SQL Sever配置管理器”
3.将下载的sqljdbc42.jardriver in yourjdk中lib目录下
进行连接测试
(1)打开SQL server 数据库,新建一个数据库test.
(2)运行eclipse新建一个project,然后新建一个包,包里新建一个java文件,Main文件
(3)然后将sqljdbc42.jar复制到该project中,选择该文件后,右键点击Build Path
*关于Build Path还可以:右键单击工程名,依次选择 Build Path → Configure Build Path,Select on the right side of the window that opens Libraries标签,然后单击 Add External JARs,找到 sqljdbc42.jar 文件并打开,然后单击 OK Complete the configuration of the build path.
(4)然后进入Main.javafile copy the following code into it
package cn.edu.gues;
import java.sql.*;
public class Main {
public static void main(String [] args)
{
String driverName="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String dbURL="jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test";//test为你的数据库名
String userName="sa";//你的数据库用户名
String userPwd="123";//你的密码
try
{
Class.forName(driverName);
System.out.println("加载驱动成功!");
}catch(Exception e){
e.printStackTrace();
System.out.println("加载驱动失败!");
}
try{
Connection dbConn=DriverManager.getConnection(dbURL,userName,userPwd);
System.out.println("连接数据库成功!");
}catch(Exception e)
{
e.printStackTrace();
System.out.print("SQL Server连接失败!");
}
}
}(5)运行
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128950.html原文链接:https://javaforall.cn
边栏推荐
- ARC117E Zero-Sum Ranges 2
- [ARC092D] Two Faced Edges
- Study Notes - Becoming a Data Analyst in Seven Weeks "Week 2: Business": Business Analysis Metrics
- jsArray数组复制方法性能测试2207300040
- (论文翻译]未配对Image-To-Image翻译使用Cycle-Consistent敌对的网络
- shell script flow control statement
- 3年软件测试经验面试要求月薪22K,明显感觉他背了很多面试题...
- 深度操作系统DeepinOS安装步骤和MySQL安装测试
- CF338E Optimize!
- 群晖系统安装相关文件分享
猜你喜欢
随机推荐
人社部公布“数据库运行管理员”成新职业,OceanBase参与制定职业标准
eclipse连接SQL server数据库「建议收藏」
el-table中el-table-column下的操作切换class样式
Learning notes - 7 weeks as data analyst "in the first week: data analysis of thinking"
桌面软件开发框架大赏
(HR Interview) Most Common Interview Questions and Skilled Answers
Data Middle Office Construction (5): Breaking Enterprise Data Silos and Extracting Data Value
sql中ddl和dml(sql与access的区别)
shell script flow control statement
华为7年经验的软件测试总监,给所有想转行学软件测试的朋友几点建议
LeetCode二叉树系列——145.二叉树的后序遍历
Flask框架——Sijax
R语言使用aov函数进行单因素协方差分析(One-way ANCOVA)、使用effects包中的effect函数来计算调整后的分组均值(calculate adjusted means)
jsArray array copy method performance test 2207292307
Skywalking入门
重保特辑|筑牢第一道防线,云防火墙攻防演练最佳实践
cookie模拟登录「建议收藏」
永州动力电池实验室建设合理布局方案
No-code development platform application visible permission setting introductory tutorial
No-code development platform all application settings introductory tutorial









