# Database Drivers

Updated: 7/3/2020, 10:40:39 AM
Created: 7/3/2020, 10:40:39 AM
Last Updated By: Mike Street
Read Time: 3 minute(s)

# Description

The jBASE design provides for database independence by allowing end users to code additional database drivers thus enabling a infinite number of database types to be used by the same application. In addition jBASE provides an example of how to interface to the jBASE jEDI drivers.

# Example of an application interface into jBASE jEDI Drivers

Copy the "jediCExample.c" program from the "src" subdirectory in the jBASE release directory and compile.

# UNIX #1

cc jediCExample.c -o CExample -I$JBCRELEASEDIR/include -ljedi -lld
1

# Windows #1

cl /Zi -o CExample jediCExample.c /I%JBCRELEASEDIR%\include libjbase.lib
1

Execute CExample as:

CExample -Options InputFile OutputFile
1

where Options may be:

  • -c Clear OutputFile before copy,
  • -d Delete records from InputFile after copy,
  • -o Overwrite OutputFile records.

# Example of jBASE JEDI Driver

Copy the "jediDExample.c" program from the "src" subdirectory in the jBASE release directory and compile.

# UNIX #2

cc jediDExample.c -c -I$JBCRELEASEDIR/include
jBuildSLib jediDExample.o -o $HOME/lib/ddrivers.so
1
2

# Windows #2

cl /Zi /c jediDExample.c /I%JBCRELEASEDIR%\include
jBuildSLib jediDExample.obj -o %HOME%\lib\libdrivers.dll
1
2

# Create jBASE File Pointer #1

ED . EXAMPLE
001 JBC__SOB ExampleInit .d
1
2

# Create standard directory with ".d" suffix

mkdir EXAMPLE.d
1

# Edit jBASE File Pointer #1

ED EXAMPLE 1 2 3
1

# List directory EXAMPLE.d

jdir or ls EXAMPLE.d
1

# Example jBASE JEDI Subroutine Driver

Copy the "GEN_SUB.b" program from the "src" subdirectory in the jBASE release directory and compile.

jbc -c GEN_SUB.b
jBuildSLib -o $HOME/lib/libGEN.so GEN_SUB.o
jBuildSLib -o %HOME%\lib\libGEN.so GEN_SUB.obj
1
2
3

# Create normal HASH files

CREATE-FILE GENFILE 1 1
1

# Create jBASE File Pointer #2

ED . GENFILEX
JBC__SOB JediInitSUB GEN_SUB GENFILE
1
2

# Edit jBASE File Pointer #2

ED GENFILEX 1 2 3
1

# List hash file

LIST GENFILE
1

# Example jBASE JEDI Subroutine Driver for ORACLE on Windows

Copy the "ORA_SUB.b" program and "sqlsubs.pc" from the "src" subdirectory in the jBASE release directory and precompile with ORACLE compiler and then compile.

Set library path to include Oracle libraries

set lib=%ORACLE_HOME%\pro21\lib;%lib%
1

Set jBASE environment variables for ORACLE NT libraries and precompiler options.

set JBC_SQLPREPROC=proc21 mode=oracle iname=
set JBC_SQLLIBS=/MD SQLLIB17.LIB
1
2

Copy jBASE jmv.exe to move.exe as required by jbc -Jqo options

cp C:\JBASE30\bin\jmv.exe C:\JBASE30\bin\move.exe
1

In SQL*PLUS create SQL table:

SQL> CREATE TABLE ORATABLE ( ORAID VARCHAR(8) NOT NULL PRIMARY KEY, ORARECORD VARCHAR2(1500));
1

Precompile sqlsubs error functions:

proc21 mode=oracle iname=sqlsubs.pc
1

Compile sqlsubs.c in to a .obj

cl /c /Zi /D_X86=1 /DWIN32 sqlsubs.c /IC:\JBASE30\include
1

Precompile the ORA_SUB.b subroutine:

jbc -c -Jqo -Jv ORA_SUB.b
1

Build a dynamic linked library contain your subroutine and error functions:

jBuildSLib -o libORA.dll ORA_SUB.obj sqlsubs.obj -l SQLLIB17.LIB
1

Copy dll and def to your %HOME% "lib" subdirectory so it can be found by jEDI:

cp libORA.dll %HOME%\lib
cp libORA.def %HOME%\lib
cp libORA.lib %HOME%\lib
1
2
3

Create jBASE File Pointer

ED . EXAMPLE1
Top
.I
000+ JBC__SOB JediInitORA ORA_SUB ORATABLE
000+
.FI
1
2
3
4
5
6

Access SQL table via jEDI subroutine driver

ED ORATABLE A B C
LIST ORATABLE
COUNT ORATABLE
1
2
3

In SQL*PLUS check updates

See also jEDI

Back to Knowledgebase