public class AS400JDBCDriver
extends java.lang.Object
implements java.sql.Driver
To use this driver, the application or caller must register the driver with the JDBC DriverManager prior to JDBC 4.0. This class also registers itself automatically when it is loaded. When using the JDBC 4.0 or later versions, the driver is automatically registered.
After registering the driver, applications make connection requests to the DriverManager, which dispatches them to the appropriate driver. This driver accepts connection requests for databases specified by the URLs that match the following syntax:
jdbc:as400://system-name/default-schema;properties
The driver uses the specified system name to connect to a corresponding IBM i system. If an IPV6 address is used as the system name, it must be enclosed within braces, i.e. [fd13:ac12:18:17::16]. If a system name is not specified, then the user will be prompted.
The default SQL schema is optional and the driver uses it to resolve unqualified names in SQL statements. If no default SQL schema is set, then the driver resolves unqualified names based on the naming convention for the connection. If SQL naming is being used, and no default SQL schema is set, then the driver resolves unqualified names using the schema with the same name as the user. If system naming is being used, and no default SQL schema is set, then the driver resolves unqualified names using the server job's library list. See JDBC properties for more details on how to set the naming convention and library list.
Several properties can optionally be set within the URL. They are separated by semicolons and are in the form:
name1=value1;name2=value2;...See JDBC properties for a complete list of properties supported by this driver.
The following example URL specifies a connection to the database on system mysystem.helloworld.com with mylibrary as the default SQL schema. The connection will use the system naming convention and return full error messages:
jdbc:as400://mysystem.helloworld.com/mylibrary;naming=system;errors=full
Modifier and Type | Field and Description |
---|---|
static int |
JDBC_MAJOR_VERSION_ |
static int |
JDBC_MINOR_VERSION_ |
Constructor and Description |
---|
AS400JDBCDriver() |
Modifier and Type | Method and Description |
---|---|
boolean |
acceptsURL(java.lang.String url)
Indicates if the driver understands how to connect
to the database named by the URL.
|
java.sql.Connection |
connect(AS400 system)
Connects to the database on the specified system.
|
java.sql.Connection |
connect(AS400 system,
boolean clone)
Connects to the database on the specified system.
|
java.sql.Connection |
connect(AS400 system,
java.util.Properties info,
java.lang.String schema)
Connects to the database on the specified system.
|
java.sql.Connection |
connect(AS400 system,
java.util.Properties info,
java.lang.String schema,
boolean clone)
Connects to the database on the specified system.
|
java.sql.Connection |
connect(java.lang.String url,
java.util.Properties info)
Connects to the database named by the specified URL.
|
java.sql.Connection |
connect(java.lang.String url,
java.util.Properties info,
char[] password)
Connects to the database named by the specified URL.
|
java.sql.Connection |
connect(java.lang.String url,
java.lang.String userid,
char[] password)
Connects to the database named by the specified URL using the
specified userid and password.
|
int |
getMajorVersion()
Returns the driver's major version number.
|
int |
getMinorVersion()
Returns the driver's minor version number.
|
java.sql.DriverPropertyInfo[] |
getPropertyInfo(java.lang.String url,
java.util.Properties info)
Returns an array of DriverPropertyInfo objects that
describe the properties that are supported by this
driver.
|
boolean |
jdbcCompliant()
Indicates if the driver is a genuine JDBC compliant driver.
|
java.lang.String |
toString()
Returns the name of the driver.
|
public static final int JDBC_MAJOR_VERSION_
public static final int JDBC_MINOR_VERSION_
public boolean acceptsURL(java.lang.String url) throws java.sql.SQLException
acceptsURL
in interface java.sql.Driver
url
- The URL for the database.java.sql.SQLException
- If an error occurs.public java.sql.Connection connect(java.lang.String url, java.lang.String userid, char[] password) throws java.sql.SQLException
url
- The URL for the database.userid
- The userid for the connectionpassword
- The password for the connection. The caller should clear the
password from the array after the method returns.java.sql.SQLException
- If the driver is unable to make the connection.public java.sql.Connection connect(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
connect
in interface java.sql.Driver
url
- The URL for the database.info
- The connection properties.java.sql.SQLException
- If the driver is unable to make the connection.public java.sql.Connection connect(java.lang.String url, java.util.Properties info, char[] password) throws java.sql.SQLException
url
- The URL for the database.info
- The connection properties.password
- The password as a char array. The caller should clear the
char array after returning.java.sql.SQLException
- If the driver is unable to make the connection.public java.sql.Connection connect(AS400 system) throws java.sql.SQLException
Note: Since this method is not defined in the JDBC Driver interface, you typically need to create a Driver object in order to call this method:
AS400JDBCDriver d = new AS400JDBCDriver(); AS400 o = new AS400(myAS400, myUserId, myPwd); Connection c = d.connect (o);
system
- The IBM i system to connect.java.sql.SQLException
- If the driver is unable to make the connection.public java.sql.Connection connect(AS400 system, boolean clone) throws java.sql.SQLException
Note: Since this method is not defined in the JDBC Driver interface, you typically need to create a Driver object in order to call this method:
AS400JDBCDriver d = new AS400JDBCDriver(); AS400 o = new AS400(myAS400, myUserId, myPwd); Connection c = d.connect (o, false);
system
- The IBM i system to connect.clone
- True if the AS400 object should be cloned, false otherwise.java.sql.SQLException
- If the driver is unable to make the connection.public java.sql.Connection connect(AS400 system, java.util.Properties info, java.lang.String schema, boolean clone) throws java.sql.SQLException
Note: Since this method is not defined in the JDBC Driver interface, you typically need to create a Driver object in order to call this method:
AS400JDBCDriver d = new AS400JDBCDriver(); AS400 o = new AS400(myAS400, myUserId, myPwd); String mySchema = "defaultSchema"; Properties prop = new Properties(); Connection c = d.connect (o, prop, mySchema, false);
system
- The IBM i system to connect.info
- The connection properties.schema
- The default SQL schema or null meaning no default SQL schema specified.clone
- True if the AS400 object should be cloned, false otherwise.java.sql.SQLException
- If the driver is unable to make the connection.public java.sql.Connection connect(AS400 system, java.util.Properties info, java.lang.String schema) throws java.sql.SQLException
Note: Since this method is not defined in the JDBC Driver interface, you typically need to create a Driver object in order to call this method:
AS400JDBCDriver d = new AS400JDBCDriver(); String mySchema = "defaultSchema"; Properties p = new Properties(); AS400 o = new AS400(myAS400, myUserId, myPwd); Connection c = d.connect (o, p, mySchema);
system
- The IBM i system to connect.info
- The connection properties.schema
- The default SQL schema or null meaning no default SQL schema specified.java.sql.SQLException
- If the driver is unable to make the connection.public int getMajorVersion()
getMajorVersion
in interface java.sql.Driver
public int getMinorVersion()
getMinorVersion
in interface java.sql.Driver
public java.sql.DriverPropertyInfo[] getPropertyInfo(java.lang.String url, java.util.Properties info) throws java.sql.SQLException
getPropertyInfo
in interface java.sql.Driver
url
- The URL for the database.info
- The connection properties.java.sql.SQLException
- If an error occurs.public boolean jdbcCompliant()
jdbcCompliant
in interface java.sql.Driver
public java.lang.String toString()
toString
in class java.lang.Object