All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mockrunner.example.jdbc.OrderDB Maven / Gradle / Ivy

Go to download

Mockrunner is a lightweight framework for unit testing applications in the J2EE environment. It supports servlets, filters, tag classes and Struts actions. It includes a JDBC a JMS and a JCA test framework and can be used to test EJB based applications.

The newest version!
package com.mockrunner.example.jdbc;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * This example calls a stored procedure that returns all the names
 * for a specified date.
 */
public class OrderDB
{
    public static List getNames(Date date) throws SQLException
    {
        Connection connection = DriverManager.getConnection("jdbc:db2://127.0.0.1/test");
        CallableStatement statement = connection.prepareCall("call getnames(?)");
        statement.setDate(1, date);
        ResultSet result = statement.executeQuery();
        List resultList = new ArrayList();
        while(result.next())
        {
            resultList.add(result.getString("name"));
        }
        result.close();
        statement.close();
        connection.close();
        return resultList;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy