connect()

Description:

Establish a connection to a database.

Syntax:

connect(dataSource)

 

connect(drv,url)

Connect to a database through its driver and url in which the user name and password are written

connect()

Return the connection to a data source in the file system.

Note:

The function establishes a data source connection. Return the connection to a data source in the file system when parameters are absent.

Parameters:

dataSource

The name of a data source

drv

Database driver class

url

Database driver connection URL

Options:

@l

 

@e

Return field names and table names in lower case; by default it’s the database that handles the cases

If there is an error, return an error message to be processed automatically with the code; without the option, an interrupt occurs.

@ncurs

Transaction isolation levels for the connection, corresponding respectively to  none, commit, uncommit, repeatable, and serializable.

Return value:

Data source connection

Example:

 

A

 

1

=connect("demo")

Connect to the data source demo. If any database operation error occurs, the data source connection will be interrupted.

2

=connect@e("demo")

Connect to the data source demo. For any operation on this connection, if any error occurs, a message will be returned and processed by code.

3

=connect@c("demo")

Connect to the data source demo, with the transaction isolation level being commit.  

4

=connect("org.hsqldb.jdbcDriver","jdbc:

hsqldb:hsql://127.0.0.1/demo?user=sa")

Leave the password blank.

5

=connect("com.mysql.jdbc.Driver","jdbc:

mysql://127.0.0.1:3306/mysqlwp?user=root

&password=root")

 

6

=connect()

Connect to the file system

7

=connect@l("demo")

Connect to demo datasource and return field names and table names in lower case

8

=A7.query("select * from DEPT")

Related functions:

db.close()

db.error()

db.commit()

db.rollback()