BBjAPI::getJDBCConnection

Description

In BBj 9.00 and higher, this method returns a java.sql.Connection, implemented as a BBjCollapsableJDBCConnection, to the specified JDBC connection URL or BBj database.

Syntax

Return Value

Method

java.sql.Connection

getJDBCConnection(string url)

java.sql.Connection

getJDBCConnection(string url, string mode)

In BBj 16.00 and higher, this method returns a JDBC connection to the specified JDBC connection URL or BBj database.

Return Value

Method

java.sql.Connection

getJDBCConnection(string url , java.util.Properties props )

java.sql.Connection

getJDBCConnection(string url , string user, string password)

Parameters

Variable

Description

mode

List of properties and values separated by commas. These properties will be passed to the database or JDBC connection at connect time.  For example:

USER=myusername,PWD=mypass,AUTOCOMMIT=N

password

In BBj 16.00 and higher, specifies password for the user.

props

In BBj 16.00 and higher,java.util.Properties object containing name/value pairs to be passed to the server for the connection configuration.

url

The name of a BBj database on the server, or the JDBC connection URL used to connect to a remote or third party database, If passing in a BBj database name, ensure that the name exactly matches the name defined in the Enterprise Manager, including case. If specifying a JDBC URL, consult the JDBC driver documentation for the specific driver to get information regarding the format and content of the connection URL.

user

In BBj 16.00 and higher, specifies user name to use for authentication.

Return Value

Returns a BBjCollapsableJDBCConnection object that represents a connection to the specified database. This object is an implementation of the JDBC java.sql.Connection interface that allows the application access to the complete functionality of the JDBC API. This gives the developer additional flexibility and functionality not available with the standard SQL verbs and BBjRecordSets.

Remarks

It is very important to note that this method does not require an additional license. The license will be collapsed into the current license that the user received when running the application. However, a BBjCollapsableJDBCConnection object may not be used in any third party libraries or applications launched from BBj.  To do this, the application must get a new JDBC Connection using the following code:

myCon! = java.sql.DriverManager.getConnection(url)

Example

rem 'Make a connection to a BBj database

myCon! = BBjAPI().getJDBCConnection("ChileCompany", "")

rem 'Get a java.sql.PreparedStatement instance
stmt! = myCon!.prepareStatement("select * from customer")

rem 'Execute the query and get a java.sql.ResultSet
rs! = stmt!.executeQuery()

See Also

BBjAPI

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.