jdbc:mysql://localhost:3306/db_librarySys Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/db_librarySys?user=root&password=1234");Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/db_librarySys", "root", "1234");...
连接mysql的url写法
jdbc:mysql://<hostname>[<:3306>]/<dbname>jdbc:mysql://localhost:3306/db_librarySysConnection conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/db_librarySys?user=root&password=1234");Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/db_librarySys", "root", "1234");2014-04-01
这样:
jdbc:mysql://<hostname>[<:3306>]/<dbname>
jdbc:mysql://localhost:3306/db_librarySys
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/db_librarySys?user=root&password=1234");
Connection conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/db_librarySys", "root", "1234");
扩展资料:注意事项
URL=协议名+子协议名+数据源名。
1、协议名总是“jdbc”。
2、子协议名由JDBC驱动程序的编写者决定。
3、数据源名也可能包含用户与口令等信息;这些信息也可单独提供。
URL:jdbc:oracle:thin:@machine_name:port:dbname
注:machine_name:数据库所在的机器的名称;
port:端口号,默认是1521
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
//orcl为数据库的SID
String user="test";
String password="test";
Connection conn= DriverManager.getConnection(url,user,password);
注意:Oracle的URL有两种写法:
1、jdbc:oracle:thin:@localhost:1521:databaseName 常用操作sql的工具:sqlDeveloper.exe,还可以用其他数据库,如mysql等
2、jdbc:oracle:oci:@localhost:1521:databaseName 用来操作SQL的工具只能用:PL/SQL Developer;数据库集群时候常用此连接,比上面那个多点功能,性能好点。
2019-10-25
racle数据库>jdbc:oracle:thin:@localhost:1521:sid
SqlServer数据库>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=sid
MySql数据库>jdbc:mysql://localhost:3306/sid
常用参数:useUnicode=true&characterEncoding=UTF-8
如果在mysql集群搭建的时候,没有配置各节点的主从关系,那么这些节点都是平等的,就用 jdbc:mysql:loadbalance: 这种方式操作集群数据库.2015-06-15
跟数据库进行连接的时候,用来连接到指定远程数据库标识符,可以在该URL中指定连接用户名和密码,同时,对于不同的数据库有不同的标示。例如连接一个本地机器上的SQLServer数据库的URL如下:jdbc:sqlserver://localhost;user=MyUserName;password=*****;2018-09-08
你是做java的吧2014-04-01