Database Connection Quick Reference
This section provides links to quick information on how to get connected to a Pervasive PSQL database.
These examples should only supplement the full documentation for each access method. For each access method, there are links to more detailed information.
Each sample references the Course table in the DEMODATA sample database, which is included with Pervasive PSQL.
•
ADO.NET Connections
•
ADO/OLE DB Connections
•
JDBC Connections
•
Java Class Library
•
DSN-Less Connections
ADO.NET Connections
For complete information on ADO.NET tasks, see
•
Using the Data Providers
in
Data Provider for .NET Guide
•
The code examples provided when you install the sample headers and files (the Web download of the ADO.NET samples and header files).
Sample ADO.NET DB Connection Code
"ServerDSN=Demodata;UID=test;PWD=test;ServerName=localhost;";
ADO/OLE DB Connections
For complete information on ADO/OLE DB tasks, see
•
OLE DB Provider Introduction
•
Programming with the Pervasive OLE DB Provider
Sample ADO/OLE DB Connection Code
Dim rs As New ADODB.Recordset
rs.Open "Course", "Provider=PervasiveOLEDB;Data
Source=DEMODATA", adOpenDynamic,
adLockOptimistic, adCmdTableDirect
’ work with data
rs.Close
JDBC Connections
For complete information on JDBC tasks, see
•
Introduction to the Pervasive JDBC Driver
•
Programming with the Pervasive JDBC 2 Driver
Sample JDBC Connection Code
Class.forName("com.pervasive.jdbc.v2.Driver");
Connection con = DriverManager.getConnection("jdbc:pervasive://localhost:1583/DEMODATA");
PreparedStatement stmt = con.prepareStatement("SELECT * FROM Course ORDER BY Name");
ResultSet rs = stmt.executeQuery();
Java Class Library
For complete information on Java Class Library tasks, see
•
Introduction to the Pervasive Java Interface
•
Programming with the Java Class Library
Sample JCL Connection String
Session session = Driver.establishSession();
Database db = session.connectToDatabase();
db.setDictionaryLoc("c:\\PVSW\\DEMODATA");
DSN-Less Connections
Pervasive PSQL allows an application to perform a DSN-less connection (connecting to the SQL engine without using a DSN) :
The following steps should be used when running locally on the Server or from a Remote Client. This method works with Server as well as Workstation/WorkGroup Engines.
1
SQLAllocEnv
2
SQLAllocConnect
3
SQLDriverConnect: "Driver={Pervasive ODBC Client Interface};ServerName=<ServerName to Resolve>;dbq=@<ServerSide DBName>;"
Example
Driver={Pervasive ODBC Client Interface};ServerName=myserver;dbq=@DEMODATA;
Note:
Releases earlier than Pervasive.SQL 2000 (SP3) supported DSN-less connections only for applications running local to the engine (i.e. running on the same machine where the engines were running). However, the format of the Driver string changed starting with Pervasive.SQL 2000i (SP3). Any applications using DSN-less connections will have to be modified as shown above, and recompiled in order to run without a DSN under Pervasive.SQL 2000 (SP2a) or earlier.