Enterprise Manager logoEM: Databases/SQL: Databases > JDBC How-To

Description

The Databases, JDBC How-To provides administrators with all required JDBC connection details for accessing a BASIS database, including the JDBC Driver JAR, JDBC Driver Class, and Connect URL. It also provides ready-to-use Java and BBj code examples, enabling developers and administrators to configure, test, and implement JDBC database connections correctly and efficiently.

Note: selecting a database from Databases name list, opens its configuration interface, enabling access to JDBC How-To and other databases.

Location

Enterprise Manager logoEM NavigatorDatabases/SQLDatabasesJDBC How-To

JDBC Connection Instructions Settings

Settings Description
JDBC Driver JAR The JDBC driver JAR required for BASIS database connectivity access.
JDBC Driver Class The fully qualified JDBC driver class used for database connectivity.
JDBC Connect URL The JDBC connection string required to establish database connectivity from applications.

The sample codes below will change based on the database selected. In these examples the administrator can copy and paste codes in a java application or a BBj Application to access the Chile Company Database.

Sample Java Code

Class.forName("com.basis.jdbc.BasisDriver");

String url = "jdbc:basis:hgenc:2001?DATABASE=ChileCompany&SSL=false";
Connection con = DriverManager.getConnection(url, "youruser", "yourpassword");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM my_table");
while (rs.next())
{
    System.out.println(rs.getString("MY_CHAR_COLUMN"));
}
rs.close();
stmt.close();
con.close();

Sample BBj Code

chan = SQLUNT
url$ = "jdbc:basis:hgenc:2001?DATABASE=ChileCompany&SSL=false"
SQLOPEN(chan, MODE="USER=youruser,PWD=yourpwd") url$
SQLPREP(chan) "SELECT * FROM my_table"
SQLEXEC(chan)
DIM rec$:SQLTMPL(chan)
WHILE 1
    rec$ = SQLFETCH(chan, ERR=finished)
    PRINT rec.MY_CHAR_COLUMN$
WEND
finished:
SQLCLOSE(chan)

See Also

BBjAdminBase

Databases

SQL

Tables

Views

Procedures

Types

Security

Query Analysis

Permissions

Connection Pools

SQL/SELECT Connections

Table Analysis Queue

Index Builders