If you think the Android project jepldroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*
Copyright 2011 Jose Maria Arranz Santamaria
/*fromwww.java2s.com*/
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/package jepl.impl;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import jepl.JEPLException;
import jepl.JEPLPreparedStatement;
/**
*
* @author jmarranz
*/publicabstractclass JEPLPreparedStatementImpl extends JEPLStatementImpl implements JEPLPreparedStatement
{
protected String key;
public JEPLPreparedStatementImpl(JEPLConnectionImpl jcon,JEPLDALImpl dalDeleg,PreparedStatement stmt,String key) throws SQLException
{
super(jcon,dalDeleg,stmt);
this.key = key;
}
public PreparedStatement getPreparedStatement()
{
return (PreparedStatement)stmt;
}
publicvoid setParameters(Object[] paramList) throws SQLException
{
PreparedStatement stmt = getPreparedStatement();
for(int i = 0; i < paramList.length; i++)
{
Object par = paramList[i];
setObject(stmt,i + 1,par); // EMPIEZA EN 1 !!
}
}
protectedvoid setObject(PreparedStatement stmt,int index,Object param) throws SQLException
{
stmt.setObject(index,param);
}
public String getKey()
{
return key;
}
public ResultSet executeUpdateGetGeneratedKeys(String sqlJDBC) throws Exception
{
// sqlJDBC no se usa aqui, es para la sobrecarga de Android
PreparedStatement stmt = getPreparedStatement();
int count = stmt.executeUpdate();
if (count == 0) thrownew JEPLException("No row has been inserted"); // Si hay transaccion se abortara la operacion
if (count > 1) thrownew JEPLException("More than a row has been inserted");
return stmt.getGeneratedKeys();
}
publicvoid moveResultSetAbsolutePosition(ResultSet result,int position) throws SQLException
{
// La razon de este metodo tan simple y en JEPLPreparedStatement es que es sobreescrito en Android
result.absolute(position);
}
publicboolean isExecuteUpdateReturnCorrect()
{
// La razon de este metodo es que se redefine en Android
return true;
}
}