Defining the Connection Properties

From InterBase
Jump to: navigation, search

Connection properties must also be defined before trying to open a database connection. To do this, pass in a java.util.Properties object, which maps between tag strings and value strings. Two typical properties are “user” and “password.” First, create the Properties object:

java.util.Properties properties = new java.util.Properties();

Now create the connection arguments. user and password are either literal strings or string variables. They must be the username and password on the InterBase database to which you are connecting:

properties.put (“user”, "sysdba");
properties.put (“password”, "masterkey");

Now create the connection with the URL and connection properties parameters:

java.sql.Connection connection =
java.sql.DriverManager.getConnection(url, properties);