学习路上的杂事坑

学习路上的杂事坑,第1张

学习路上的杂事/坑
  • mac上的eclipse安装sqljdbc驱动,jdk15会出错,换成1.8就好了
  • 连接数据库的代码:
package test;

import java.sql.*;

class Test{
	public static void main(String[] args) {
	// TODO Auto-generated method stub
		try {
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			System.out.println("驱动加载成功");
			
			Connection conn=DriverManager.getConnection(
					"jdbc:sqlserver://10.120.123.1:1433;DatabaseName=YGGL","SA","yxr010527!"
					);
			System.out.println("连接数据库成功");
			
			Statement st=conn.createStatement();
			String sqldelete="delete from departments where departmentID='011';";
			st.executeUpdate(sqldelete);
			st.close();
			System.out.println(sqldelete);
		}
		catch(Exception e) {
			e.printStackTrace();
		}
	
	}
}```

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5678115.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存