con el siguiente código
Código:
public void ejecutar(ArrayList sqls) throws Exception {
conexion.setAutoCommit(false);
try {
Statement st = conexion.createStatement();
for (int i =0; i<sqls.size(); i++){
String sql = String.valueOf(sqls.get(i));
st.executeUpdate(sql);
}
conexion.commit(); // ejecuta
st.close();
} catch (SQLException e) {
try {
conexion.rollback();
} catch (SQLException e1) {
e1.printStackTrace();
} //algo falló
System.out.println("Error al ejecutar sql.\n" + e.getMessage());
}
finally{
try{
conexion.setAutoCommit(true);
}
catch (SQLException e) {
System.out.println("Error.\n" + e.getMessage());
}
}
}
Me lanza esto:
java.sql.SQLException: [Microsoft][Controlador ODBC Microsoft Access]No se puede definir el atributo ahora
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLSetConnectOption(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcConnection.setAutoCommit(Unk nown Source)
en la linea del
conexion.setAutoCommit(false);
por favor si alguien puede ayudarme, el Autocommit no lo tengo muy claro y debo estar haciendo algo mal.
Gracias