## Class com.sap.dbtech.jdbcext.DataSourceSapDB

### Use

To connect the Java application to the database instance and to open a database session, you can use the com.sap.dbtech.jdbcext.DataSourceSapDB class (part of sapdbc.jar). This class implements the interface javax.sql.DataSource of the Sun Java platform. You can find more information at java.sun.com.

Alternatively, you can use the java.sql.DriverManager.getConnection Method of the Java platform.

### Prerequisites

● You have started the X Server (see X Server, Starting the X Server)

You have to start the X Server even if the Java application and the database instance are on the same computer.

● You have loaded the JDBC driver.

### Features

Methods of the com.sap.dbtech.jdbcext.DataSourceSapDB Class

Method | Task
<type> get<property_name>() | Query the value of the property
void set<property_name>(<type> <value>) | Set the value for the property

<property_name> = Name of the property (see below), the first letter of the name is written in upper case

String getCache()

String getDatabaseName()

Properties of DataSourceSapDB objects

<property_name> | Default Value | Description

cache

-

Specifies, for which SQL statements in Prepared Statements the JDBC driver saves information (for example, on the used parameters) in a dedicated cache

Possible values:

● all: all SQL statements

● Combination of the following letters

s (SELECT statements)

i (INSERT statements)

u (UPDATE statements)

d (DELETE statements)

cache=iud

The database system saves information on INSERT, UPDATE and DELETE statements in the cache.

databaseName | - | Database name
description | - | Description of your choice
loginTimeout | 30 | Timeout for the logon (in seconds)
password | - | Password
port | 7210 | Port of the X Server on the database computer. See X Server, Ports and Protocols of the X Server
reconnect | on | RECONNECT mode Possible values: on: The system automatically reconnects to the database instance after a command timeout. off: There is no automatic new connection.
serverName | localhost | Database computer
sqlMode | INTERNAL | SQL mode ORACLE | INTERNAL
timeout | - | Timeout for the database session (in seconds) If you specify this connection option, you override the timeout that has been configured for the database instance with the special database parameter SESSION_TIMEOUT (see Concepts of the Database System, Special Database Parameters).
trace | - | <directory>/<jdbc_trace_file> If you specify this connection option, then the database system writes a JDBC trace in the <jdbc_trace_file> file in the directory <directory>.
traceSize | - | Maximum number of lines in the JDBC trace file. If this number of lines is exceeded, the database system begins to overwrite the content of the JDBC trace file
transport | socket | Communication method for communicating with the DBM server Possible values: socket: TCP/IP connection secure: SSL connection, see Set Up SSL Connection
unicode | false | Unicode Support true: the JDBC driver sends the user name, password and SQL statements in Unicode to the database instance false: the JDBC driver uses ASCII
url | - | Connection URL
user | - | Name of the database user

You can also transfer most properties as connection options within the connection URL url. The following properties are exceptions: description, databasename, servername, url, port, loginTimeout.

### Example

Examples: Connecting to the Database Instance