Developing Web-based Applications
This section describes how to create web-based applications with the Pervasive JDBC driver.
Applets
To develop web based applications using JDBC, you need to place the JDBC jar file in the codebase directory containing the applet classes.
For example, if you are developing an application called MyFirstJDBCapplet, you need to place the pvjdbc2.jar file (or the pervasive jdbc package) in the directory containing the MyFirstJDBCapplet class. For example, it might be C:\inetpub\wwwroot\myjdbc\. This enables the client web browser to be able to download the JDBC driver over the network and connect to the database.
Also, if you use the JAR file, you need to put the archive parameter within the <APPLET> tag. For example,
<applet CODE="MyFirstJDBCapplet.class" ARCHIVE="pvjdbc2.jar" WIDTH=641 HEIGHT=554>
*Note: The Pervasive PSQL engine must be running on the web server that hosts the applet.
Servlets and Java Server Pages
Servlets and Java Server Pages (JSP can be used to create web-based applications with the Pervasive JDBC Driver.
The following is a sample Java Server Page for displaying one table in the DEMODATA sample database included with Pervasive PSQL
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
 
<%
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();
%>
 
<html>
<head>
<title>Pervasive PSQL JSP Sample</title>
</head>
<body>
 
<h1>Pervasive PSQL JSP Sample</h1>
<h2>Course table in DEMODATA database</h2>
<p>
This example opens the Course table from the DEMODATA
database included with Pervasive PSQL and
displays the contents of the table
</p>
 
<table border=1 cellpadding=5>
<tr>
<th>Name</th>
<th>Description</th>
<th>Credit Hours</th>
<th>Department Name</th>
</tr>
 
 
<% while(rs.next()) { %>
<tr>
<td><%= rs.getString("Name") %></td>
<td><%= rs.getString("Description") %></td>
<td><%= rs.getString("Credit_Hours") %></td>
<td><%= rs.getString("Dept_Name") %></td>
</tr>
<% } %>
 
</table>
 
</body>
</html>
Information on Servlets and JSP
For more information about servlets and JSP, see Sun’s Web site at java.sun.com.