PreviousProgrammer's Guide (9.1 revision 1) Next

Database Connection Quick Reference

Show this topic in Library frames

This section provides links to quick information on how to get connected to a Pervasive.SQL 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.SQL.

ADO/OLE DB Connections

For complete information on ADO/OLE DB tasks, see

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

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

Sample JCL Connection String

Session session = Driver.establishSession();  
Database db = session.connectToDatabase(); 
db.setDictionaryLoc("c:\\PVSW\\DEMODATA");  

DSN-Less Connections

Pervasive.SQL 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.


Chapter contents
Publication contents

Prev topic: Choosing a Development Tool
Next topic: Where to Go from Here