Code example for Statement

Methods: close, executeQuery, executeUpdate

0
			statement = connection.createStatement();
		} catch (SQLException e) {
			System.out.println("ExceptionGetConn: " + e.toString());
		} 
		String sqlmaxId = "SELECT MAX(id_evenement) AS newId FROM evenement";
		rs = statement.executeQuery(sqlmaxId);
		EventEntity eventEntity =null;
		eventEntity = new EventEntity();	
		boolean val = rs.next();
		if (val == false) {
			eventEntity.setId_evenement(0);
			statement.close();
		} else {  
			int newRow=rs.getInt(1)+1;
			String sqlInsert="INSERT INTO evenement (id_evenement,evenement_libelle,evenement_id_android,evenement_sync)" +" VALUES('" + newRow+ "','" + evenement_libelle+ "','" +newRow+ "'+1,evenement_sync)";
			int rows = statement.executeUpdate(sqlInsert);
			if(rows>0){
				eventEntity.setId_evenement(newRow);
				System.out.println("ID_EVENEMENT ORACLE: " + newRow);
			}else{ 
				eventEntity.setId_evenement(0);
			} 
			statement.close();
		}	 
		connection.close();
		return eventEntity;
	}