This section describes the LIBNAME statement that SAS/ACCESS Interface to JDBC supports. For general information about this feature, see LIBNAME Statement for Relational Databases.
Here is the LIBNAME statement syntax for accessing JDBC.
For general information about the LIBNAME statement that is not specific to SAS/ACCESS, see LIBNAME Statement in SAS Global Statements: Reference.
specifies any SAS name that serves as an alias to associate SAS with a database, schema, server, or group of tables and views.
JDBCspecifies the SAS/ACCESS engine name for the JDBC interface.
provide connection information and control how SAS manages the timing and concurrence of the connection to the DBMS.
Here is how these options are defined.
lets you connect to a JDBC database with a user ID that is different from the default ID. USER= is optional.
Alias: UID=
specifies the JDBC password that is associated with your user ID. PASSWORD= is optional. If the password contains spaces or nonalphanumeric characters, enclose it in quotation marks. If you do not want to enter your JDBC password in uncoded text on this statement, see PROC PWENCODE in the Base SAS Procedures Guide for a method to encode it.
Alias: PWD=
specifies the JDBC driver to use for your database connection.
Alias: CLASS=
Example: driverclass="org.postgresql.Driver"
specifies additional resources, including JDBC drivers, to add to the JDBC class path. In SAS 9.4M9, third-party JDBC driver files must be installed in a required location. CLASSPATH= enables you to specify an alternate class path if you need a different class path for some LIBNAME statements. The directory-path must be a subdirectory of the required location. Most users do not need the CLASSPATH= option. When used, the CLASSPATH= option must be used in conjunction with the DRIVERCLASS= option.
/SASHOME/AccessClients/9.4/DataDrivers/jdbc
or, if SASHOME is not set:
/usr/local/SAS/AccessClients/9.4/DataDrivers/jdbc
SASHOME\AccessClients\9.4\DataDrivers\jdbc
or, if SASHOME is not set:
C:\Progam Files\SASHome\AccessClients\9.4\DataDrivers\jdbc
specifies the JDBC connection string to use for your database connection.
Example: url="jdbc:postgresql://<server>:<port>/test"
See your JDBC driver documentation for a list of the JDBC connection options that your JDBC driver supports.
specify how SAS processes DBMS objects. Some LIBNAME options can enhance performance, and others determine locking or naming behavior. The following table describes the LIBNAME options for SAS/ACCESS Interface to JDBC, with the applicable default values. This table also identifies LIBNAME options that are valid in the CONNECT statement in the SQL procedure.For details, see LIBNAME Options for Relational Databases.
|
Option |
Default Value |
Valid in CONNECT Statement |
|---|---|---|
|
none |
|
|
|
none |
|
|
|
YES if BULKLOAD=NO and your JDBC driver supports batch updates NO otherwise |
||
|
YES |
● |
|
|
SHAREDREAD |
● |
|
|
matches the maximum number of bytes per single character of the SAS session encoding |
||
|
none |
● |
|
|
none |
● |
|
|
none |
|
|
|
DBMS |
● |
|
|
none |
|
|
|
none |
|
|
|
1024 |
● |
|
|
LONG |
||
|
NO |
|
|
|
COMPAT |
|
|
|
NO |
● |
|
|
YES |
|
|
|
none |
|
|
|
none |
|
|
|
The trace log is overwritten and includes no time stamps or thread identification. |
|
|
|
based on row length |
|
|
|
0 |
● |
|
|
NONE |
|
|
|
none |
|
|
|
NO |
|
|
|
NO |
|
|
|
0 |
● |
|
|
none |
||
|
automatically calculated based on row length |
● |
|
|
none |
|
|
|
YES |
|
|
|
none |
|
|
|
none |
|
|
|
none |
|
|
|
none |
||
|
ERROR |
● |
In this example, USER=, PASSWORD=, URL=, and DRIVERCLASS= are connection options.
libname mydblib JDBC user=myusr1 password=mypwd1
url="jdbc:postgresql://<server>:<port>/myDB"
driverclass="org.postgresql.Driver";
In this next example, the libref MYLIB uses the JDBC engine to connect to a PostgreSQL database. The connection options are DRIVERCLASS=, URL=, USER=, PASSWORD=, and CLASSPATH=. The CLASSPATH= LIBNAME option indicates that the vendor’s JDBC driver JAR file is contained in the C:\Progam Files\SASHome\AccessClients\9.4\DataDrivers\jdbc\postgresql directory.
libname x JDBC driverclass="org.postgresql.Driver"
user=myuser
password="mypwd1"
classpath="C:\Progam Files\SASHome\AccessClients\9.4\DataDrivers\jdbc\postgresql"
URL="jdbc:postgresql://myserver:myport/<postgres-database>";
proc print data=x.customers;
where state='CA';
run;