- 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(); } } }```
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)