使用JDBC连接到安全数据库

时间:2021-05-20 09:49:58

How do you specify the username and password for a JDBC connection when acessing a secure database?

在访问安全数据库时,如何指定JDBC连接的用户名和密码?

2 个解决方案

#1


You should be able to specify them in DriverManager.getConnection(), like

您应该能够在DriverManager.getConnection()中指定它们,就像

Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@" + dbname,
                                              dbusername, dbpassword);

#2


The DriverManager.getConnection method has a signature which takes a username and password. In addition, JDBC drivers tend to support specifying them on the URL

DriverManager.getConnection方法具有签名,该签名采用用户名和密码。此外,JDBC驱动程序倾向于支持在URL上指定它们

#1


You should be able to specify them in DriverManager.getConnection(), like

您应该能够在DriverManager.getConnection()中指定它们,就像

Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@" + dbname,
                                              dbusername, dbpassword);

#2


The DriverManager.getConnection method has a signature which takes a username and password. In addition, JDBC drivers tend to support specifying them on the URL

DriverManager.getConnection方法具有签名,该签名采用用户名和密码。此外,JDBC驱动程序倾向于支持在URL上指定它们