标签:test cte dex out exception erp stack print span
public class JdbcTest { public static void main(String[] args) { String dbURL = "jdbc:sqlserver://127.0.0.1:1433; DatabaseName=数据库名"; // 连接字符串 String userName = "sa"; String userPwd = "123456"; try { Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //驱动 Connection dbConn = DriverManager.getConnection(dbURL, userName, userPwd); System.out.println("连接数据库成功"); } catch (ClassNotFoundException | SQLException e) { e.printStackTrace(); System.out.print("连接失败"); } } }
SQLServer如上。
MySQL如下:
public class JdbcTest { public static void main(String[] args) { String dbURL = "jdbc:mysql://localhost:3306/数据库名"; // 连接字符串 String userName = "sa"; String userPwd = "123456"; try { Class.forName("com.mysql.jdbc.Driver"); //驱动 Connection dbConn = DriverManager.getConnection(dbURL, userName, userPwd); System.out.println("连接数据库成功"); } catch (ClassNotFoundException | SQLException e) { e.printStackTrace(); System.out.print("连接失败"); } } }
【MySQL】SQLServer、MySQL中JDBC驱动和连接字符串
标签:test cte dex out exception erp stack print span
原文地址:https://www.cnblogs.com/to-red/p/10312057.html