<x:driverManagerSpec>

A x:driverMangerSpec action is used to specify information needed to make a connection to a JDBC database using the JDBC driver manager. However, the x:driverManagerSpec action does not establish the connection. It does create an object which can be referenced within the scope of this page by x:select, x:modify, x:procedureCall, or x:batch actions, or in scriptlets. The database connection is established when those actions are processed.

 

Syntax

<x:driverManagerSpec
             id = "name"
            scope = "page|request|session"    
            driver = "database_driver_name"
            url = "jdbc:subprotocol:subname"
            userid = "db_user"
            password = "user_password"
            passwordEncrypted = "true|false" />

The x:driverManagerSpec action has the following attributes:

id

The name used to identify a DBConnectionSpec bean in the specified namespace, and also its scripting variable name. The name specified is case sensitive and must conform to the current scripting language variable naming conventions.

scope

The namespace within which the object is defined. The default value is page.

userid

A required attribute that specifies a valid user ID for the database to be accessed. Case will be preserved as entered.

password

A required attribute that specifies the password for the user ID. Case will be preserved as entered.

passwordEncrypted

An optional attribute that specifies whether the value specified in the password attribute is encrypted or not . The default value is false. The encryption algorithm is unique to the underlying bean. Therefore, to pass an encrypted password, obtain the password from a tool that knows how to encrypt it. The advantage of doing this is that your JSP will not contain a readable password.

driver

A required attribute that specifies the JDBC driver to use when establishing a connection to the database. This is the class name of the JDBC driver (including the package name). For example, the DB2 application JDBC driver is COM.ibm.db2.jdbc.app.DB2Driver. Case will be preserved as entered.

url

A required attribute specifying the URL to use when establishing a connection to the database. Case will be preserved as entered. A URL specification has the format jdbc:subprotocol:subname, where subprotocol and subname identify the data source for the connection. The value of subprotocol depends on the JDBC driver used. For example, for the DB2 application JDBC driver, subprotocol is db2; for the Oracle thin driver, subprotocol is thin. The value of subname depends on the subprotocol specification; the subname value provides information to locate the database. For example, a full URL specification for an application accessing a local database named sample through the DB2 application JDBC driver is: jdbc:db2:sample. By comparison, a full URL specification for an applet using the Sybase jConnect driver to access a database named sample, on a remote server named myserv, through port number 88 on the internet is: jdbc:sybase:Tds:myserver:88/sample. Here, the subname value includes the database server name, port number, and database name.

 

Examples

This example uses the driver and url attributes to specify how to connect to a database, and uses values for the user ID and password supplied at runtime by the user.

<x:driverManagerSpec id="conn1"  
    driver = "COM.ibm.db2.jdbc.app.DB2Driver" 
    url = "jdbc:db2:sample"
    userid = '<%= request.getParameter("userid") %>'
    password = '<%= request.getParameter("password") %>' />