xcall SQL, SQLOP_CONNECT, cmdhdr, connectstring
This operation establishes a connection to a specific database.
Parameters
cmdhdr (ST_SQL_CMDHDR), [in/out]
The fields of interest to this opcode in the cmdhdr structure (defined in SQL.DEF) are listed below.
Field |
Dir |
Notes |
---|---|---|
handle |
in |
handle to connection (returned from SQLOP_INIT_CONN) |
dbmsconid |
in |
|
opflags |
in |
For DBMSCONID_MYSQL, you can optionally pass MySQL Connection Flags |
cmdarg1,2 |
n/a |
|
rc |
out |
return code (0 = ok, see SQLERR_xxx) |
rcext |
out |
extended error code |
info1,2 |
n/a |
|
sqlstate |
out |
ANSI standard SQL state code |
reshdl |
n/a |
|
psthdl |
n/a |
|
connectstring [string, in]
A string containing command-line-style parameters needed to establish the connection. The general syntax consists of “-param=value” pairs, each separated by a space. The parameters include:
-host
The hostname (or IP address) of the machine hosting the database server. For ODBC, specify the name of the data source. Note that depending on the data source configuration, it may eliminate the need to specify the login and/or database name. See History.
-user
The user name to connect to the database. See History.
-pw
The password to connect to the database. See History.
-db
The database (or schema) name. If not specified, you can still connect to the server and then use SQL metadata queries, such as SHOW DATABASES (MySQL) to see which are available, and USE <table> to use a specific one.
-flags
Optional connection flags, expressed as the decimal sum of MYCF_xxx values (for MySQL) for the desired options (see Appendix)
-port
Optional port number, required only when port is not the default value
Examples
connectstring = “-host=localhost –user-me –password=secret db=sakila”
connectstring = “-host=Jack’s data source” ! (ODBC)
connectstring = “Jack’s data source” ! (ODBC) (-host= is optional)
History
2014 June, ashmysql connector version 1.4.193: The values of the -host, -user, and -pw and parameters may now be encrypted, using any of the 3 encryption modes supported described by MX_PWCRYPT.