Neoview Guide to Stored Procedures in Java (R2.5)
• maxPoolSize=0
• minPoolSize=1
• initialPoolSize=1
To change these settings, use the properties parameter of the
DriverManager.getConnection() method as shown below:
java.util.Properties props = new Properties();
props.setProperty("maxPoolSize", "10");
props.setProperty("minPoolSize", "5");
props.setProperty("initialPoolSize", "5");
Connection conn = DriverManager.getConnection("jdbc:default:connection", props);
For details about the JDBC Type 4 driver properties, see the HP Neoview JDBC Type 4 Programmer's
Reference.
Using JDBC Method Calls
The Neoview platform uses a JDBC Type 4 driver internally to execute the SQL statements inside
an SPJ method. To enable an SPJ to perform SQL operations on a Neoview database, use JDBC
method calls in the SPJ method. The JDBC method calls must be supported by the JDBC Type 4
driver of the Neoview platform. For example, if you want the SPJ method to operate on a Neoview
Release 2.3 database, use the JDBC API that is supported by Neoview Release 2.3. For information
about the Neoview JDBC Type 4 Driver, see the Neoview JDBC Type 4 Driver Programmer’s Reference
and the Neoview JDBC Type 4 Driver API Reference.
NOTE: You do not have to explicitly load the JDBC driver before establishing a connection to
the Neoview database. Neoview SQL automatically loads the JDBC driver when the SPJ is called.
Here is an example of an SPJ method, adjustSalary(), that uses JDBC method calls to adjust
an employee’s salary in the EMPLOYEE table:
public class Payroll {
public static void adjustSalary(BigDecimal empNum,
double percent,
BigDecimal[] newSalary)
throws SQLException
{
Connection conn = DriverManager.getConnection("jdbc:default:connection");
PreparedStatement setSalary =
conn.prepareStatement("UPDATE persnl.employee " +
"SET salary = salary * (1 + (? / 100)) " +
"WHERE empnum = ?");
PreparedStatement getSalary =
conn.prepareStatement("SELECT salary " +
"FROM persnl.employee " +
"WHERE empnum = ?");
setSalary.setDouble(1, percent);
setSalary.setBigDecimal(2, empNum);
setSalary.executeUpdate();
getSalary.setBigDecimal(1, empNum);
ResultSet rs = getSalary.executeQuery();
rs.next();
newSalary[0] = rs.getBigDecimal(1);
rs.close();
conn.close();
}
}
For other examples of SPJ methods, see Appendix A (page 65).
Accessing a Neoview Database 29