Neoview Guide to Stored Procedures in Java (R2.3, R2.4)

DAILYORDERS Procedure
The DAILYORDERS procedure accepts a date and returns the number of orders on that date to
an output parameter.
Java Method: numDailyOrders()
Example A-3 numDailyOrders() Method
public static void numDailyOrders(Date date,
int[] numOrders)
throws SQLException
{
Connection conn = DriverManager.getConnection("jdbc:default:connection");
PreparedStatement getNumOrders =
conn.prepareStatement("SELECT COUNT(order_date) " +
"FROM sales.orders " +
"WHERE order_date = ?");
getNumOrders.setDate(1, date);
ResultSet rs = getNumOrders.executeQuery();
rs.next();
numOrders[0] = rs.getInt(1);
rs.close();
conn.close();
}
Creating the Procedure: DAILYORDERS
To create this procedure in the SALES schema, upload the Sales.jar file to the Neoview
platform, navigate to the SALES schema in DB Admin, and then enter or select these values in
the Create Procedure Wizard of DB Admin. For instructions, see “Uploading SPJ JAR Files to
the Neoview Platform” (page 35) and “Creating SPJs” (page 43).
dailyordersName:
Sales.jar > Sales > numDailyOrdersCode:
First SQL parameter:
Name: none
Direction: IN
SQL Data Type: DATE
Java Data Type: java.sql.Date
Second SQL parameter:
Name: number
Direction: OUT
SQL Data Type: INTEGER
Java Data Type: int[]
Parameters:
Dynamic result sets: 0
Accesses Database: selected
Attributes:
80 Sample SPJs