src.com.ibm.as400.micro.StatementHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jt400-jdk8 Show documentation
Show all versions of jt400-jdk8 Show documentation
The Open Source version of the IBM Toolbox for Java
///////////////////////////////////////////////////////////////////////////////
//
// JTOpen (IBM Toolbox for Java - OSS version)
//
// Filename: StatementHandler.java
//
// The source code contained herein is licensed under the IBM Public License
// Version 1.0, which has been approved by the Open Source Initiative.
// Copyright (C) 1997-2001 International Business Machines Corporation and
// others. All rights reserved.
//
///////////////////////////////////////////////////////////////////////////////
package com.ibm.as400.micro;
import java.io.*;
import java.sql.*;
import java.util.*;
/**
The StatementHandler class is designed to handle all interactions
needed by the JDBC-ME driver with the JDBC Statement interface.
**/
class StatementHandler
{
private static final String copyright = "Copyright (C) 1997-2001 International Business Machines Corporation and others.";
private JdbcMeService service_;
private MicroDataInputStream in_;
private MicroDataOutputStream out_;
/**
Constructor. Creates a new JDBC-ME handler for Statement
objects.
* @param jdbcme
* @param in
* @param out
**/
public StatementHandler(JdbcMeService jdbcme, MicroDataInputStream in, MicroDataOutputStream out)
{
service_ = jdbcme;
in_ = in;
out_ = out;
}
/**
The process function routes the function id and the Statement
to the proper handler.
* @param statement
* @param funcId
* @throws IOException
**/
public void process(Statement statement, int funcId) throws IOException
{
switch (funcId)
{
case MEConstants.STMT_CLOSE:
close(statement);
break;
case MEConstants.STMT_EXECUTE:
execute(statement);
break;
default:
// TODO: This is an exception condition...
System.out.println("Error - Statement Function ID not recognized - function code: " + funcId);
break;
}
}
/**
Closes the Statement object. This function has the side effect
of closing any ResultSets that are open under it as well.
Unlike most of the methods of this class, if an exception occurs
while closing the Statement, this method will not report it back
to the caller in any way. It is simply swallowed and a message
is logged concerning the failure.
The data flow is as follows:
- nothing more