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

src.com.ziclix.python.sql.handler.UpdateCountDataHandler Maven / Gradle / Ivy

Go to download

Jython is an implementation of the high-level, dynamic, object-oriented language Python written in 100% Pure Java, and seamlessly integrated with the Java platform. It thus allows you to run Python on any Java platform.

There is a newer version: 2.7.4
Show newest version
/*
 * Jython Database Specification API 2.0
 *
 *
 * Copyright (c) 2001 brian zimmer 
 *
 */
package com.ziclix.python.sql.handler;

import com.ziclix.python.sql.DataHandler;
import com.ziclix.python.sql.FilterDataHandler;
import com.ziclix.python.sql.zxJDBC;
import org.python.core.Py;

import java.sql.SQLException;
import java.sql.Statement;

/**
 * A data handler that keeps track of the update count for each execution of a
 * Statement.
 * 

*

Note: MySql does not return the correct count for a * delete statement that has * no where clause. Therefore, to assure the correct update count is returned, * either include a where clause, or understand that the value will always be * 0.

* * @author brian zimmer * @see java.sql.Statement#getUpdateCount() */ public class UpdateCountDataHandler extends FilterDataHandler { private static boolean once = false; /** * The update count for the last executed statement. */ public int updateCount; /** * Handle capturing the update count. The initial value of the updateCount is * -1. */ public UpdateCountDataHandler(DataHandler datahandler) { super(datahandler); if (!once) { Py.writeError("UpdateCountDataHandler", zxJDBC.getString("updateCountDeprecation")); once = true; } this.updateCount = -1; } /** * Sets the update count to -1 prior to the statement being executed. */ public void preExecute(Statement stmt) throws SQLException { super.preExecute(stmt); this.updateCount = -1; } /** * Gets the update count from the statement after successfully executing. */ public void postExecute(Statement stmt) throws SQLException { super.postExecute(stmt); this.updateCount = stmt.getUpdateCount(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy