1.

How do you create a connection object?

Answer»

There are 3 overloaded DriverManager.getConnection() methods to create a connection object

getConnection(String url, String user, String password)Using a database URL with a username and password. For example

String URL = "jdbcoraclethinamrood1521EMP";String USER = "username";String PASS = "password"Connection conn = DriverManager.getConnection(URL, USER, PASS);getConnection(String url)Using only a database URL. For example
String URL = "jdbcoraclethinusername/passwordamrood1521EMP";Connection conn = DriverManager.getConnection(URL);getConnection(String url, Properties prop)Using a database URL and a Properties object. For example
String URL = "jdbcoraclethinamrood1521EMP";Properties info = new Properties( );info.put( "user", "username" );info.put( "password", "password" );


Discussion

No Comment Found