connect()

Read(2799) Label: establish, data source connection,

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 username and password are written

connect()

Used in a simple SQL query to 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.

Parameter:

dataSource

The name of a data source

drv

Database driver class

url

Database driver connection URL

Option:

@l

 

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

@e

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 data source demo. If any database operation error occurs, the data source connection will be interrupted.

2

=connect@e("demo")

Connect to 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 data source and return field names and table names in lower case.

8

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

9

=connect("com.esproc.jdbc.InternalDriver","jdbc:esproc:local://")

Connect to esproc-JDBC data source.

10

=connect("oracle.jdbc.driver.OracleDriver","jdbc:oracle:thin:root/root@127.0.0.1:1521:orcl")

Connect to oracle datasource. orcl is SID.

11

=connect("oracle.jdbc.driver.OracleDriver","jdbc:oracle:thin:root/root@//127.0.0.1:1521/snA")

Connect to oracle datasource. snA is service_name.

Related function:

db.close()

db.error()

db.commit()

db.rollback()