nerisson Pic-pic | Exemple:
Code :
- public synchronized void ajouteListeUniversReference(final Integer[] idUnivers, final Integer[] idReference, final Integer user) throws SQLException {
- /* Recupere une connexion */
- final Connection connection = getConnection();
- final String tmpTableName = "##TMP_BKT_ajouteListeUniversReference";
- try {
- /* Creation de la table temporaire */
- final String tableCreation = "create table " + tmpTableName + " " +
- "(IdReference integer not null," +
- " IdUnivers integer not null)";
- final PreparedStatement preparedStatement = connection.prepareStatement(tableCreation);
- try {
- final int nb = preparedStatement.executeUpdate();
- } finally {
- preparedStatement.close();
- }//end try
- /* Remplissage de la table temporaire */
- final Statement statement = connection.createStatement();
- try {
- statement.clearBatch();
- for(int i=0;i<idReference.length;i++) {
- final StringBuffer buffer = new StringBuffer(200);
- buffer.append("insert ##TMP_BKT_ajouteListeUniversReference values(" );
- buffer.append(idReference[i].intValue()).append("," );
- buffer.append(idUnivers[i].intValue()).append(" )" );
- statement.addBatch(buffer.toString());
- }//end for
- statement.executeBatch();
- } finally {
- statement.close();
- }//end try
- /* Prepare l'appel de la procedure */
- final String query = "{?=call BKT_ajouteListeUniversReference;1 ?}";
- final CallableStatement callableStatement = connection.prepareCall(query);
- try {
- /* Parametres de la procedure */
- callableStatement.registerOutParameter(1, java.sql.Types.INTEGER);
- register(callableStatement, user, 2);
- /* Execute la procedure */
- callableStatement.execute();
- /* Recupere le code de retour */
- final int returnValue = callableStatement.getInt(1);
- switch(returnValue) {
- case 0: // OK
- break;
- case 1: // Erreur interne
- internalError(query, returnValue);
- case 2: // Utilisateur inconnu
- unknowUser(query, returnValue, user);
- default: // Code de retour inconnu
- unknowCode(query, returnValue);
- }//end switch
- } finally {
- callableStatement.close();
- }//end try
- } finally {
- dropTable(connection, tmpTableName);
- unlockConnection(connection);
- }//end try
- }//end ajouteListeUniversReference
|
Ca ne compilera pas car il manque des methodes, mais je pense que tu pourra sans probleme les remplacer ---------------
Light is right
|