tags:

views:

109

answers:

2

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

+7  A: 

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

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

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

Yishai